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

Tell us what’s happening:

Hey there,
I have a problem understanding the task as I am not sure which variable I am assigned to Print.
Thank you for your help

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]
    for odd_digits in card_number:
        print(odd_digits)
        #mistake?
    

# 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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15

Challenge Information:

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

as per the instruction u need to use odd_digits.

correct syntax is

for variable in list:
  statement1
  .
  .
  statementn

replace list with odd_digits and print variable

I thought I was using odd_digits?

instead of i u can use any variable and just print that variable. normally we use i,j,k in that flow i wrote i but u can use any variable

in the instruction given odd_digits contain values and u need to access it and print it. not use odd_digits as a variable to access the list. here odd_digit is the list. hope u got it

2 Likes

got it now! thank you! dumb mistake lol :))

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