Learn String Manipulation by Building a Cipher - Step 39

I feel like the code i wrote is correct but, it keeps giving me the message " You should use the += operator to add char to the current value of encrypted_text". I feel like i’ve done exactly as asked and im a little confused about what im doing wrong. any help would be greatly appreciated.

Your code so far


/* User Editable Region */

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


for char in text.lower():
    if char == ' ':
        encrypted_text += 'space!'
    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 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 39

Hello!

You want to add a real space, not the string “space”. And the real space is stored in char (if True) → so what do you want to add to encrypted_text?

2 Likes

ahh okay, so i should use char instead of ‘space!’ to add a literal space to my output, thank you!

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