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

Tell us what’s happening:

I have no idea why this gives me an error regarding this task.
Create a variable named card_number_reversed and assign it the value of the first 4 characters of card_number.

Your code so far


# User Editable Region

def verify_card_number(): 
    sum_of_odd_digits = 0
    card_number_reserved = card_number[0:4]

# User Editable Region

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

    print(translated_card_number)

    verify_card_number(translated_card_number)
    
main()

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Safari/605.1.15

Challenge Information:

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

just a spelling error / typo ‘reserved’

Thank you for your reply.
I put the one below in the fourth line but it gives me an error.
card_number_reversed = card_number[0:4]

The error message says “TypeError: verify_card_number() takes 0 positional arguments but 1 was given”.
Could you possibly help me?

The task is Create a variable named card_number_reversed and assign it the value of the first 4 characters of card_number.
My latest attempt code is below and the error message is “TypeError: verify_card_number() takes 0 positional arguments but 1 was given”. I don’t know what I am doing wrong… If someone can help me, that would be really helpful.

def verify_card_number():
sum_of_odd_digits = 0
card_number_reversed = card_number[0:4]

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

print(translated_card_number)

verify_card_number(translated_card_number)

main()

Double check your arguments and parameters for your verify_card_number()

I think you accidentally changed something, you could try resetting this step and see what changes

Thank you for your advice. You were right!!I was able to solve it.

  • code removed
1 Like

It is great that you solved the challenge, but please don’t post your full working solution.

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.

Oh I didn’t know that!! I’m sorry and thank you for your help!!

1 Like

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