We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Validating Credit Card Numbers
Validating Credit Card Numbers
Sort by
recency
|
464 Discussions
|
Please Login in order to post a comment
Test case 3 is failed and i am not getting the problem where is : This is my code:
import re
def check(s): #1check if no of digits are 16 or not after removing - if len(s.replace("-",""))==16: for i in s: if i=="-" or i.isdigit(): continue else: return "Invalid"
n=int(input()) for _ in range(n): s=input() result=check(s) print(result)
import re
def is_valid(crd_no):
pattern = r"^(?!.*(\d)(?:-?\1){3})([4-6]\d{3}(-?\d{4}){3})$"
return bool(re.match(pattern, crd_no))
n = int(input())
crd_no = [input() for _ in range(n)]
for card in crd_no:
result = is_valid(card) if result:
lse: print("Invalid")