Learn String Manipulation by Building a Cipher - Step 33

Tell us what’s happening:

Now you need to create a new_char variable at the end of your loop body. Set its value to alphabet[new_index].

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

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

Your code so far

# User Editable Region
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'

for char in text:
    index = alphabet.find(char)
    print(char, index)
    new_index = index + shift
    new_char = alphabet[new_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/156.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 33

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/6552487e689f6e895f658717.md at main · freeCodeCamp/freeCodeCamp · GitHub

Welcome to the forum @nguyennhubao3103,

Your new code is correct, but you have changed the following starting code, which will cause the tests to fail:

for char in text.lower():

Please reset this step and try again, being careful not to change the starting code.

Happy code