Validating Credit Card Numbers

  • + 0 comments
    import re
    
    pattern = r'^(?!.*(\d)(\-*\1){3})[4-6]((\d{3}(\-\d{4}){3})|([\d]{15}))$'
    
    for _ in range(int(input())):
        print('Valid' if re.match(pattern, input()) else 'Invalid')