Learn String Manipulation by Building a Cipher - Step 42

Tell us what’s happening:

I am getting a syntax error and I am not sure how to fix it. I thought I was doing it right but it seems I was not

Your code so far


# User Editable Region

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

for char in text.lower():
    if char == ' ':
        print(char + encrypted_text)
    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/126.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 42

you were not asked to print anything.
Instead you were supposed to use the += operator to add char to the encrypted_text variable

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.