from html import escape

data = [
    ["Nhóm <A>", 8, 9, 7],
    ["Nhóm B & C", 7.5, 8, 9],
]

content = """<!DOCTYPE html>
<html lang="vi">
<head><meta charset="utf-8"><title>Điểm minh họa</title></head>
<body><table style="border:1px solid blue">
<caption>Điểm minh họa, dữ liệu giả định</caption>
<tr>
  <th style="border:1px solid blue" rowspan="2">Nhóm</th>
  <th style="border:1px solid blue" colspan="3">Điểm</th>
</tr>
<tr>
  <th style="border:1px solid blue">Lần 1</th>
  <th style="border:1px solid blue">Lần 2</th>
  <th style="border:1px solid blue">Lần 3</th>
</tr>
"""
for row in data:
    if len(row) != 4:
        raise ValueError("Mỗi hàng phải có bốn giá trị")
    content += "<tr>"
    for value in row:
        text = escape(str(value))
        content += '<td style="border:1px solid blue">'
        content += text + "</td>"
    content += "</tr>\n"
content += "</table></body></html>"
with open("diem_minh_hoa.html", "w", encoding="utf-8") as output:
    output.write(content)
