In this post, we will solve Valid PAN format HackerRank Solution. This problem (Valid PAN format) is a part of HackerRank Regex series.
Valid PAN format – HackerRank Solution
Python
import re p = re.compile('[A-Z]{5}[0-9]{4}[A-Z]') n = int(input()) for i in range(n): x = str(input()) if(len(x) != 10): print("NO") elif(len(re.findall(p, x)) > 0): print("YES") else: print("NO")
Note: This problem (Valid PAN Format) is generated by HackerRank but the solution is provided by CodingBroz. This tutorial is only for Educational and Learning purpose.