You are viewing a single comment's thread. Return to all comments →
my solution
import re patern =r'^[4|5|6](\d{15}|\d{3}(-\d{4}){3})' duplicate=r'(\d)(-?\1){3}' N= int(input()) for i in range(N): card= input() if len(card)<=19 and re.match(patern, card): if re.search(duplicate, card): print("Invalid") else: 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 →
my solution