You are viewing a single comment's thread. Return to all comments →
python3
import re check1 = r'(?=(.)(-?\1){3,}.*)' # repeat validcredit = r'^(4|5|6)[0-9]{3}(-?[0-9]{4}){3}$' check1 = re.compile(check1) check2 = re.compile(validcredit) t = int(input()) for i in range(t): num = input() if check1.search(num): print("Invalid") elif check2.match(num): 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 →
python3