Step 24 of Learn How to Work with Numbers and Strings by implementing the Luhn Algorithmn

I don’t know if the image uploaded, but this part is so confuzzling. I had a hard time doing it the first time. I am getting the right output, but it won’t let me continue.

def verify_card_number(card_number):
    sum_of_odd_digits = 0
    card_number_reversed = card_number[::-1]
    odd_digits = card_number_reversed[::2]
    sum_of_even_digits = 0
    even_digits = card_number_reversed[1::2]

    for digit in odd_digits:
        sum_of_odd_digits += int(digit)
    print(sum_of_odd_digits)

    for i in even_digits : 
        print(i)

Its best to post actual code and a link to the Step instead of a screenshot.


This odd extra space before the : probably shouldn’t be there

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.