Learn String Manipulation by Building a Cipher - Step 26

Tell us what’s happening:

it says i need to declare the variable index inside the for loop before printing the current character, but this code is apparently wrong

Your code so far

text = 'Hello World'
shift = 3

# User Editable Region

alphabet = 'abcdefghijklmnopqrstuvwxyz'
 index = alphabet.find(char)
 for char in text:
     index = alphabet.find(char)
 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/127.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 26

You are declaring the index variable before the “for loop”, and again inside the “for loop”. Code is executed sequentially, so your line before the “for loop” will execute first.

How ever the “for loop” creates the char variable so it does not exist. Read each line sequentially and try to follow the logic.