You are viewing a single comment's thread. Return to all comments →
import sys, re text = sys.stdin.read().splitlines()[1:] format_pattern = r"^[456]\d{3}([-]?\d{4}){3}$" match = [] for line in text: format_match = re.search(format_pattern, line) if format_match != None: occurence_match = re.search(r"(.)\1{3}", ''.join(re.split('-', line))) if occurence_match == None: match += ['Valid'] else: match += ['Invalid'] else: match += ['Invalid'] for _ in match: print(_)
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 →