Learn String Manipulation by Building a Cipher - Step 37

Tell us what’s happening:

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

for char in text.lower():
index = alphabet.find(char)
new_index = index + shift
encrypted_text. = alphabet[new_index]
print(‘char:’, char, ‘encrypted text:’, encrypted_text)

Your code so far


# User Editable Region

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

for char in text.lower():
    index = alphabet.find(char)    
    new_index = index + shift
    encrypted_text. = alphabet[new_index]
    print('char:', char, 'encrypted text:', encrypted_text)

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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 37

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

:balloon: Hi, welcome to the forum!
We see you have posted some code but did you have a question?

(You have not filled out the “Tell us what’s happening:” field above)

Hi @Grace25

The console is giving you a trace back error message.

The period does not look like it belongs there.

For next time, describe the issue in your own words. Learning to communicate problems is a part of becoming a web developer.

Happy coding

okay, sorry for the wrong communication. i have been stuck in this step for 2 days even after following the instuctions i hope. Can someone help me pass the level?

okay, sorry for the wrong communication. i have been stuck in this step for 2 days even after following the instuctions i hope. Can someone help me pass the level?

please share your updated code

i till need help with this step. i cant seem to pass it.

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

for char in text.lower():
index = alphabet.find(char)
new_index = index + shift
encrypted_text. = alphabet[new_index]
print(‘char:’, char, ‘encrypted text:’, encrypted_text)

Please read the advice above.

Check the error message in the console and see if it has a clue to the problem.

done! Thank youvery much

1 Like