Learn String Manipulation by Building a Cipher - Step 29

Tell us what’s happening:

Step 29
find is again returning -1 for uppercase letters, and for the space character, too. You are going to take care of the space later on.

For now, instead of iterating over text, change the for loop to iterate over text.lower().

text = ‘Hello World’
shift = 3
alphabet = ‘abcdefghijklmnopqrstuvwxyz’

for char in text.lower():
index = alphabet.lower(char)
print(char, index)

the site keeps saying this is incorrect. i have looked overo other forms. and this is the answer.

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'

for char in text.lower():  
    index = alphabet.lower(char)
    print(char, index)

# 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/121.0.0.0 Safari/537.36 OPR/107.0.0.0 (Edition std-1)

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 29

This line will generate an error because .lower() doesn’t take any arguments:

What do you want to accomplish with this line? The .lower() method doesn’t take any arguments:
https://www.w3schools.com/python/ref_string_lower.asp

1 Like

I don’t know hat I’m doing wrong i keep looking things up and looking things over and see nothing wrong with it.

restore this to what it was, you still want to use find here
you did the change you had to do why writing text.lower()

1 Like

instead of iterating over text, change the for loop to iterate over text.lower().

This line is correct, it was the only thing that you needed to change.

You can reset the step and try it again.

1 Like

i just needed to remove the char in that line of code. did we have to do that because the loop said text.lower() ?

i needed to change index = alphabet.lower(char) to index = alphabet.lower()

the tests do not check if you have find or not in that line. but python is really strict with the number of parameters and arguments, lower() expects 0 arguments, if you give it a different number of arguments you get an error that stop the execution of the code