You are viewing a single comment's thread. Return to all comments →
import re def isvalid(a): pattern=r"^[456]\d{15}|[456]\d{3}(\-\d{4}){3}$" if not re.match(pattern,a): return False a=a.replace("-","") if re.findall(r"(\d)\1{3,}",a): return False return True for _ in range(int(input())): a=input() print("Valid" if isvalid(a) else "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 →