My solution for Luhn's algorithm
card_number = 371449635398431
print(card_number)
def validation_card_number(card_number):
card_number = str(card_number)
selected_number = card_number[1::2]
print(selected_number)
other_number = card_number[::2]
print(other_number)
sum1 = 0
for i in selected_number:
value = int(i)*2
value = str(value)
value = [int(v) for v in value]
value = sum(value)
sum1 = sum1 + value
print("Sum 1:", sum1)
sum2=0
for v in other_number:
sum2 = sum2 + int(v)
print("Sum 2:", sum2)
total = sum1 + sum2
print("The Total:", total)
if total%10 == 0:
return print("Check: The card number is valide")
else:
return print("Check: The card number is not valide")
card_number = input("Give me a card number to check :>")
validation_card_number(card_number)