Valid PAN format

  • + 0 comments

    My solution for Python 3:

    import re
    N = int(input())
    regex_pat = r'^[A-Z]{5}[\d]{4}[A-Z]{1}$'
    for _ in range(N):
        line = input()
        matched_pan = re.search(regex_pat, line)
        if bool(matched_pan):
            print("YES")
        else:
            print("NO")