import re
def check(row):
problems = []
if not re.fullmatch(r"[A-Z]{2}\d{8}", row.get("invoice_no") or ""):
problems.append("發票號碼格式不對")
if not re.fullmatch(r"\d{8}", row.get("seller_tax_id") or ""):
problems.append("統編格式不對")
amounts = [row.get("sales"), row.get("tax"), row.get("total")]
if None in amounts:
problems.append("金額有缺")
elif amounts[0] + amounts[1] != amounts[2]:
problems.append("銷售額加稅額不等於總計")
if row.get("confidence") != "high":
problems.append("信心不足")
return problems
good = {"invoice_no": "AB12345678", "seller_tax_id": "12345678", "sales": 1000, "tax": 50, "total": 1050, "confidence": "high"}
bad = {"invoice_no": "AB1234", "seller_tax_id": None, "sales": 1000, "tax": 50, "total": 1060, "confidence": "low"}
print(check(good))
print(check(bad))