Learn String Manipulation by Building a Cipher - Step 40

Tell us what’s happening:

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

for char in text.lower():
print(char==‘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():
    print(char=='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 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 40

Welcome to the forum @gperemkumar

You should compare char with a space using the equality operator inside your for loop.

Your comparison is with the string text.lower, not a space.

Happy coding

Please remember to talk about how you are stuck instead of just posting the code. Thanks