You are viewing a single comment's thread. Return to all comments →
import re def isValidCard(s): return bool(re.match(r"(?!.*(\d)(-?\1){3})[4-6]\d{3}(-?\d{4}){3}$", s)) print(*["Valid" if isValidCard(input()) else "Invalid" for _ in range(int(input()))], sep="\n")
import re print(*["Valid" if re.match(r"(?!.*(\d)(-?\1){3})[4-6]\d{3}(-?\d{4}){3}$", input()) else "Invalid" for _ in range(int(input()))], sep="\n")
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 →