Learn String Manipulation by Building a Cipher - Step 42

Tell us what’s happening:

Describe your issue in detail here.

Your code so far

# User Editable Region

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

for char in text.lower():
    if char == ' ':
        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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 42

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

Hi, welcome to the forum!

Do you have a question or is there something in the instructions that’s not clear?

Are you getting any hints or error messages? Remember to check the console for more clues.

it says to print (space!) in teh clue section and I did but it doesn’t work

Looks like you are printing “True”

1 Like

it says the if condition should evaluate to true if something yk

It’s just describing how an if condition works. The condition will evaluate to true or false, you don’t need to code it.

if char == ' ':

This will either be true and execute code or false.



just print as in and dont forget to put your cursor inbetween ‘’ and hit the space button. type all the same. this is another annoying one, because the description is not clear.

— solution code deleted—

meaning that if CHAR is empty, which it is not, then dont do anything, but if CHAR is equal to something, which it is then print space!

@jay2kowalski You can see from the OP code, they have the space in the quotes correct.

The IF statement could be described like this:
If char is equal to a space character then print “space!”

If you have more questions about this, please open your own topic, and please don’t add solution code, thanks!

Oh alright thank you.