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

Tell us what’s happening:

Hello!
Asked: Move the print call below the number reassignment.
I’ve done it. But it doesn’t work. How can do this?

Your code so far

/* User Editable Region */

 sum_of_even_digits = 0
even_digits = card_number_reversed[1::2]
 for digit in even_digits:
    number = int(digit) * 2
    if number >= 10:
        number = (number // 10) + (number % 10)
        print(number)

/* User Editable Region */

Your browser information:

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

Challenge Information:

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

Your code looks correct other than the indentation. I don’t know if the indentation is just displaying incorrectly on the forum or if it’s also incorrect in your challenge window?
This is the starting code for this step:

    sum_of_even_digits = 0
    even_digits = card_number_reversed[1::2]
    for digit in even_digits:
        number = int(digit) * 2
        if number >= 10:
            print(number)
            number = (number // 10) + (number % 10)

The indentation shouldn’t change, only order of the commands within the if statement.
Try resetting the step and then moving the print statement without modifying anything else.

Yeah, I know. I checked all indentations. In addition, I’ve tried with your code but it doesn’t work! And I did Solution 30. This lesson, has a similar code to my code in Solution 29. I’ve done other Solutions

The code I posted is the starting code for that step. It’s not a solution. All that is required to pass the step however is to Reset the lesson to restore that starting code and then change the order of these two lines, without changing any indentation:

print(number)
number = (number // 10) + (number % 10)

If you make any other modifications at all, your code will likely not pass.

Yes, I know. I think this problem occurred with my browser. I changed it so it ran! Thanks for your help!

Same here, then I changed the browser from Chrome to Safari, and it worked.

Solution Removed

Hi, welcome to the forum!

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

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