I want to validate a PAN card whose first 5 characters are alphabets, the next 4 are numbers and the last character is an alphabet again. I can't use isalnum() because I want to check this specific order too, not just verify whether it contains both numbers and letters.
Here is a snipped of my code:
def validate_PAN(pan):
for i in pan:
pan.isalpha(pan[0:4])==True:
return 1
pan.isdigit(pan[5:9])==True:
return 1
pan.isalpha(pan[9])==True:
return 1
else:
return 0
This obviously returns an error since it is wrong. How can I fix this?