You are viewing a single comment's thread. Return to all comments →
import re def validator(cc): if not re.fullmatch(r'[456](\d{3})(-?\d{4}){3}', cc): return False cc = cc.replace('-', '') if re.search(r'(\d)\1{3,}', cc): return False return True for i in range(int(input())): if validator(input()): print('Valid') else: print('Invalid')
Seems like cookies are disabled on this browser, please enable them to open this website
Validating Credit Card Numbers
You are viewing a single comment's thread. Return to all comments →