Learn String Manipulation by Building a Cipher - Step 30 can you give me just the assign to know where is the mistake in my code

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'

for char in text.lower():
    new_index = index + shift
    index = alphabet.find(char)
    print(char, index)

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 30

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.

At the end of your loop body, declare a variable called new_index and assign the value of index + shift to this variable.

You have the correct code, but it is in the wrong place. It should be at the end of the loop body, not the beginning.

1 Like

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