Learn String Manipulation by Building a Cipher - Step 42

I couldn’t seems to understand what to do here next, I’ve tried all I could, I still couldn’t get through. I need help on what to do next.

Your code so far


# User Editable Region

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

for char in text.lower():
    if char == ' ' = True 
    print('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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 42

This is almost correct but your if statement will automatically evaluate to True or False, so you don’t need = True. You should end that line with a colon (:) though.
Also, ensure that the print() command below it is indented four spaces into the if statement.

if char == ’ ':
print():
I guess i’m closing in on it. But it’s still asking me to “print the string 'space!' inside your new if statement.” where would i place the string into?

Your print() command was correct before. Whatever you want to print, you put inside the parentheses.

1 Like

Inside the print(…)
Mind your indentation in the if block

1 Like