luhn's solution
cardno=[3,7,1,4,4,9,6,3,5,3,9,8,4,3,1]
sum_1=[]
sum_2=[]
for i in range(len(cardno)):
if i%2!=0:
multiby2=cardno[i]*2
if multiby2<10:
sum_1.append" rel="noopener" data-mce-href="sum_1.append">sum_1.append" rel="noopener" data-mce-href="sum_1.append">sum_1.append(multiby2)
else:
tens=multiby2//10
ones=multiby2%10
sum_1.append(tens)
sum_1.append(ones)
else:
sum_2.append(cardno[i])
print(sum_1)
print(sum_2)
sum_3=sum_1+sum_2
sum_t=sum(sum_3)
print(sum_t)
if sum_t%10==0:
print('valid')
else:
print('not')
0 answers ( 0 marked as helpful)