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

Tell us what’s happening:

I’m stuck here. I tried many times but I didn’t figured it out. Please help to pass this level.

Your code so far

def verify_card_number(card_number):
    pass


# User Editable Region

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

    print(translated_card_number)


# 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 8

why do you have the definition for verify_card_number twice?

first reset and inside function def main() after print call the function.

I dont understand. I reset and should I use “Def verify_card_number(translated_card_number):” formula after print function?

no, to simply call a function we do functionname(). in this case we need to pass argument so functionname(argument)

I see some confusion here. Why did you change this?

You changed the name of the function, that should be main. You should call verify_card_number within the main function.

Ok I think I should use this formula right?
def main(verify_card_number):

If you reset your code you will see that the main function is declared with def main():. You should not change that line.

You should add a line of code to the main function body (the body is the indented code inside the function, after the :) and call the verify_card_number function with translated_card_number as the argument.

To call a function x with argument y you do x(y).

I got it. I try but error still continue. I did not change the def main(): function.

I did like this. I mentioned below. I dont understand where the wrong thing is

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

    print(translated_card_number)

you can’t use a variable before defining it. On the first line of the function, translated_card_number doesn’t exist yet

1 Like

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