You are viewing a single comment's thread. Return to all comments →
Uisng Python one liners:
import re pattern = r"^[456](?!.*(\d)(?:-?\1){3})(\d{3}-?\d{4}-?\d{4}-?\d{4})$" def validate_credit_card(string): match = re.match(pattern, string) return "Valid" if match else "Invalid" if __name__ == "__main__": T = int(input()) results = [validate_credit_card(input()) for card in range(T)] print("\n".join(results))
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 →
Uisng Python one liners: