Search
 
SCRIPT & CODE EXAMPLE
 

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")
Comment

PREVIOUS NEXT
Code Example
Python :: python for loop float increment 
Python :: pyad create user 
Python :: google scikit learn decision tree 
Python :: python split string on char 
Python :: How to convert datetime in python 
Python :: pandas if nan, then the row above 
Python :: pure imagination 
Python :: container with most water python code leetcode 
Python :: sqlalchemy one to one foreign key 
Python :: clear terminal in python 
Python :: reverse list in python 
Python :: python linear search 
Python :: how to create multiple file in python using for loop. 
Python :: how to use custom activity in discord.py 
Python :: Passing Arrays to Methods 
Python :: import modules given the full path python 
Python :: how to check whether input is string or not 
Python :: compare dates in python 
Python :: python get output 
Python :: how to print 0 to 10 in python 
Python :: python collection 
Python :: remove deprecation warning python 
Python :: image deblurring python 
Python :: beautiful soup find 
Python :: df to dict 
Python :: not intersection list python 
Python :: list comprehension with square numbers python 
Python :: pandas show all dataframe method 
Python :: requesting with aiohttp 
Python :: fetch image url discord py 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =