Learn String Manipulation by Building a Cipher - Step 37

Tell us what’s happening:

I feel like I did everything the question asked for. But it says my code is still wrong. Is there any reason why this is wrong?

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
    new_char = alphabet[new_index]
    encrypted_text = ''
    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/131.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 37

You should replace new_char with encrypted_text inside your for loop.

You didn’t do this.

2 Likes

Ohhh! Now I see it. I was confused what it meant, because I did already replace new_char with encrypted_text in the print line, not the actual string name.

1 Like