Learn String Manipulation by Building a Cipher - Step 26

Tell us what’s happening:

i have declared a new variable named index with the assigned value but my code cant pass. the lesson instructs that “i should declare a new variable at the beginning of the for loop.” I AM STUCK! I need help

Your code so far

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

# User Editable Region

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

# 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/ Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 26

Welcome to the forum @iamusman

Inside the for loop, before printing the current character, declare a variable called index and assign the value returned by alphabet.find(char) to this variable.

Keyword before, your code has it outside the for loop.

Happy coding

The traceback error message also mentions that an indented block is expected after the for loop. I got OFF there as well

1 Like

If you’re still getting an error, can you please share your updated code?