Learn String Manipulation by Building a Cipher - Step 41

Tell us what’s happening:

I have relaced the words exactly as told, what went wrong 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 41

You didn’t finish the required task to pass the challenge: “… Inside the if body, print the string 'space!' . Remember to indent this line.”

You need to add a print function as a part of the if statement and pass 'space! to the function as an argument. This code line should be indented.

I added space but it still doesn’t work, how do i upload my edited work

When you want to enter a code block into a forum post, precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Inside the if statement means below it, and indented. Move the print() function with its argument to the next line indented:

if char == ' ':
    here goes the print function

I definitely improved, but I don’t get the problem yet

Your indentation for the if statement is still wrong.

https://www.w3schools.com/python/gloss_python_if_statement.asp

As I said and showed, the print statement must be indented (for four blank spaces, on the right).

What indent shouldI use in the if statement

Look at the link I sent. Or search for the answer.

I completed the step thanks

1 Like

I intended it and then it worked, Thanks

1 Like