Learn String Manipulation by Building a Cipher - Step 39

Hey to any one reading this I already try everything i can think of to try to get this right but nothing is working the way it should I try to go to the forus and i try to do everything that they have place there and us my knowledge and still nothing have go my way to fix this. can someone tell me what im doing wrong please and thank you

#this is what i have so far

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

for char in text.lower():
    if char == " ":
        encrypted_text += " "
    index = alphabet.find(char)
    new_index = index + shift
    encrypted_text += alphabet[new_index]
    print('char:', char, 'encrypted text:', encrypted_text)

i need some help to continue to the next step.

I’ve edited your code for readability. When you enter a code block into a forum post, please 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 (').

this starts as a string with a space inside, it doesn’t seem like it should be that

please can you provide the link to the step?

1 Like

sure this is the link:

you need to have code that writes “if char is a space, add char to encrypted_text

1 Like

thank very much this help me with the answer.

1 Like