Learn String Manipulation by Building a Cipher - Step 23

Tell us what’s happening:

Describe your issue in detail here.

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
alphabet.find(char)
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/120.0.0.0 Safari/537.36 Edg/120.0.0.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 23

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

You need to put the new line in the loop, right before the print.

Before printing the current character,

index=alphabet.find(char) //char does not exist so you cannot refer to it

for char in text: // char is created here and assigned the first element of text
    print(char) // now you can use char

The char variable is only created when the loop is declared. It does not exist before the loop when you try to access it. If you want to use char it needs to be in the for loop.

1 Like