Tell us what’s happening:
Hi. I just wanted to mention that the instruction says “double the value of every other digit.”
But in the provided example, it seems -in the table- that only the even positions are doubled.
Your code so far
def verify_card_number(card):
card=card.replace('-', '').replace(' ', '')
v=int(card[len(card)-1])
print('init', v)
for i in range(len(card)-1):
r = int(card[i])*2
if r > 9:
r-= 9
print(card[i], r)
v+= r
return 'INVALID!' if v%10 else 'VALID!'
print(verify_card_number('453914889'))
Your browser information:
User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Mobile Safari/537.36
Challenge Information:
Implement the Luhn Algorithm - Implement the Luhn Algorithm