You are viewing a single comment's thread. Return to all comments →
import re cc = int(input()) for i in range(cc): val_cc = input() pattern = (r"^[4-6]\d{3}(-?\d{4}){3}$") clean_cc = val_cc.replace("-", "") if (re.search(pattern, val_cc)) and len(clean_cc) == 16 and not (re.search(r"(\d)\1{3}", clean_cc)): 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 →