Learn String Manipulation by Building a Cipher - Step 40

Tell us what’s happening:

I do not know how to do this question. Please help me

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
    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/126.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 40

Hi there, welcome to fcc community.

Here are some example about comparing 2 objects:

Example 0:

2 > 1

will check if 2 is greater than 1. The returned value is: True


Example 1:

2 >= 1

will check if 2 is greater than or equal to 1. The returned value is: True


Example 2:

2 <= 1

will check if 2 is less than or equal to 1. The returned value is: False


Example 3:

"a" == "b"

will check if "a" is equal to "b". The returned value is: False.


Now, the instruction asked us to:

At the beginning of your loop body, print the result of comparing char
with a space (' '). Use the equality operator == for that.

That means:

At the beginning of the for loop body, we will check if char is equal to a space (' '), then print the returned result to see if it is True or False

1 Like

Hello there. So after I put
print('char' == ' ')
the outcome is False. I submitted it but it doesn’t let me pass. Do you know why?

Welcome to the forum @houdinihwang

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Happy coding