Learn How to Work with Numbers and Strings by Implementing the Luhn Algorithm - Step 22

Tell us what’s happening:

Describe your issue in detail here.

Your code so far


# User Editable Region

def verify_card_number(card_number):

    sum_of_odd_digits = 0
    card_number_reversed = card_number[::-1]
    odd_digits = card_number_reversed[::2]
    print()
    for digit in odd_digits:
        sum_of_odd_digits += int(digit)
    print(sum_of_odd_digits)
  

# User Editable Region

def main():
    card_number = '4111-1111-4555-1142'
    card_translation = str.maketrans({'-': '', ' ': ''})
    translated_card_number = card_number.translate(card_translation)

    verify_card_number(translated_card_number)

main()

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36

Challenge Information:

Learn How to Work with Numbers and Strings by Implementing the Luhn Algorithm - Step 22

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.
Learning to describe problems is hard, but it is an important part of learning how to code.
Also, the more you say, the more we can help!

1 Like

I don’t understand this level, I tried to put it under and over, it’s not correct

Hi, you have written another print call. That is not what you are asked here, though.
Reset the challenge. Then create a new variable in the way that you are instructed.
Does that help?

1 Like

no it still doesn’t work
def verify_card_number(card_number):

sum_of_odd_digits = 0
card_number_reversed = card_number[::-1]
odd_digits = card_number_reversed[::2]

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

sum_of_odd_digits = 0

Have a look again at the name of your new variable. This is not what you were asked to call it.

ooooooooooooo thanks, I didn’t pay attention to this, sorry I’ll be more careful in the future

1 Like

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