You are viewing a single comment's thread. Return to all comments →
import re n = int(input()) credit_cards = [] def validate_credit_card_numbers(credit_cards): pattern = r'^(?=[456])(?!.*(\d)(-?\1){3})\d{4}(-?\d{4}){3}$' for credit_card in credit_cards: if re.match(pattern, credit_card): print('Valid') else: print('Invalid') for i in range(n): nums = input() credit_cards.append(nums) validate_credit_card_numbers(credit_cards)
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 →