Tell us what’s happening:
Hello,
i cant get these tests to pass.
The function seems working.
Am i missing a requiered output?
Can you please help me?
Your code so far
def verify_card_number(input):
account_number = ""
rev_input = input[::-1]
for char in rev_input:
if char != " " and char != "-":
account_number += char
account_number = ([int(x) for x in account_number])
check_sum = 0
for i in range(1,len(account_number),2):
account_number[i]= account_number[i] * 2
if account_number[i] > 9:
account_number[i]= account_number[i] % 10 +1
check_sum=sum(account_number)
if check_sum % 10 ==0:
print(f"{input} Valid!")
return "Valid!"
else:
print(f"{input} Invalid!")
return "Invalid!"
print(verify_card_number('453914889'))
print(verify_card_number('4111-1111-1111-1111'))
print(verify_card_number('453914881'))
print(verify_card_number('1234 5678 9012 3456'))
print(verify_card_number("453914881"))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0
Challenge Information:
Implement the Luhn Algorithm - Implement the Luhn Algorithm