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

Tell us what’s happening:

Describe your issue in detail here.
Currently working on learn how to work with numbers and string by implementing the Luhn Algorithm.
I am stuck at step 33
Adjust the verify_card_number call such that if it returns True , print VALID! to the console. Otherwise, print INVALID! .
It keeps prompting me to have the if verify_card_number(translated_card_number): within the main function.
And I am actually in the main function

Your code so far

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)

    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)
        sum_of_even_digits += number
    total = sum_of_odd_digits + sum_of_even_digits
    print(total)
    return total % 10 == 0
def main():
    card_number = '4111-1111-4555-1142'
    card_translation = str.maketrans({'-': '', ' ': ''})
    translated_card_number = card_number.translate(card_translation)

    if verify_card_number(translated_card_number):
        print(valid)
    else:
        print(invalid)

main()
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)

    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)
        sum_of_even_digits += number
    total = sum_of_odd_digits + sum_of_even_digits
    print(total)
    return total % 10 == 0

/* User Editable Region */

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

    if verify_card_number(translated_card_number):
        print(valid)
    else:
        print(invalid)

/* User Editable Region */


main()

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 33

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.

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

VALID! and INVALID! should be strings. Also the case is different from what the instructions are asking. And what about the exclamation mark?

Oh! I see. Thanks. Its working now

Please. This posting with backtick issue. I really don’t understand it.
Should I add it to code so far or to the question I am asking?

most of the time your code will be already included in the post when you press the “Ask for help” button, but if you need to include code in the post yourself, formatting it using backticks is pretty important to ensure that the code is visualized correctly, for example indentation is not shown if you don’t use backticks

Use the code button as demonstrated in the GIF.

It will add the backticks for you. (Backtick shares a key with tilde ~)