Learn String Manipulation by Building a Cipher - Step 45

Tell us what’s happening:

I am following the lesson. However, with the 3 shift, keys beyond w (or in the cypher, z) just don’t work.

Am I doing something wrong? I rewrote the same code into a python compiler and I got the same error. Please help.

Your code so far


# User Editable Region

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

for char in text.lower():
    if char == ' ':
        encrypted_text += char
    else:
        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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 45

Welcome to the forum @Skimmy404

You have a typo.

Happy coding

it will be fixed in the next few steps, your issue in this step is that you have the wrong value of text

You should still have your ‘Hello World’ there.
What they mean by assigning ‘Hello Zaira’ is not to delete the current ‘Hello World’, but to put another row after this:

Python will take ‘Hello Zaira’ as assigned to the text variable from then and you don’t have to edit the original one.

You’re welcome