Learn String Manipulation by Building a Cipher - Step 34

Tell us what’s happening:

what is going wrong with my code I keep getting the error message of You should turn your print() call into print('char:', char, 'encrypted text:', encrypted_text) . Is my code not displaying that or am I missing something?

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/120.0.0.0 Safari/537.36 OPR/106.0.0.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 34

Hey @ali.hzra,

Look at that error closely especially the string ‘encrypted text:’ and you’ll see your problem. :slight_smile:

1 Like

i feel a tiny bit stupid :joy: :joy:

No, do not feel stupid at all! There is a “couldn’t see the forest through the trees” effect where sometimes you are so deep into your own problems that all you can see are the trees ahead and you need someone with fresh eyes to come in and help you see the forest.

Happy Coding! :smiley:

1 Like

Get used to that feeling and learn to laugh at it. :+1:

Learning programming keeps us humble, even as we steal fire from the hands of the Gods.

1 Like