Learn String Manipulation by Building a Cipher - Step 14

Tell us what’s happening:

Please. Help me. try it too many time but still nothing.

Your code so far


# User Editable Region

text = 'Hello World'
text = text.lower()
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''

for char in text:
    if char in alphabet:
        # Find the current position in the alphabet
        index = alphabet.find(char)
        # Shift the index by 3 positions
        new_index = (index + shift) % len(alphabet)
        # Append the new character to the encrypted text
        encrypted_text += alphabet[new_index]
    else:
        # If the character is not in the alphabet (like spaces), add it as is
        encrypted_text += char

print(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/130.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 14

Hello there!

You deleted the original code. You need it, otherwise the tests won’t run. Reset the lesson to regain the code and only modify the existing find method.