Posted on:

10 May 2020

0

What’s wrong with my Luhn’s Algorithm?

def validation (card_n):

card_n=[]
a = card_n.reverse()
print(a)
b = []
c = []

for i in a:
if i % 2 == 0:
entry = i * 2
b.append(entry)
else:
entry = i
c.append(entry)
final_n = (sum(b) + sum(c))%10
if final_n == 0:
return "valid"
else:
return False

validation("371449635398431")

 

My error is

TypeError: 'NoneType' object is not iterable

0 answers ( 0 marked as helpful)

Submit an answer