Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

validating credit card numbers

python
import re

def check(card):
    if not re.search("^[456]d{3}(-?d{4}){3}$",card) or re.search(r"(d)1{3}", re.sub("-", "",card)):
        return False
    return True

for i in range(int(input())):
    print("Valid" if check(input()) else "Invalid")
Source by www.thepoorcoder.com #
 
PREVIOUS NEXT
Tagged: #validating #credit #card #numbers
ADD COMMENT
Topic
Name
7+2 =