Learn String Manipulation by Building a Cipher - Step 38

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 == ' ':
        print(' ')

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

/* User Editable Region */

```pls I am stuck on this if statement. Don't know where to implement the if statement so it can evaluate to true or false.
I tried using
if char == '  ':
       Print("' '")
esle:
    break
But none is working


### Your browser information:

User Agent is: <code>Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Mobile Safari/537.36</code>

### Challenge Information:
Learn String Manipulation by Building a Cipher - Step 38
https://www.freecodecamp.org/learn/scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/step-38

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.

in the if block you are writing print(’ ')
insted of this you need to write print(‘space!’)

according to this instructions:
At the top of your for loop, replace print(char == ' ') with an if statement. The condition of this if statement should evaluate to True if char is an empty space and False otherwise. Inside the if body, print the string space! . Remember to indent this line.

3 Likes

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