Learn String Manipulation by Building a Cipher - Step 37

Tell us what’s happening:

The question asks the following:
“At the top of your loop, print the result of comparing char with an empty space. Use the equality operator == for that.”
I have typed print(char == ‘’) at the beginning of the for loop but freecodecamp says this is wrong, any ideas what I should do? Thanks

Your code so far


/* User Editable Region */

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

for char in text.lower():
    print(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 (X11; Ubuntu; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 37

You are super close but this is not an empty space

This is a string with no spaces.

Once you fix that, then it will pass

8 Likes

I tried your method. It didn’t appear to work for me can you elaborate on what is different?

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 Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for 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.

Thank you.

As was mentioned earlier, it is best to create a new topic with your code so we can see the issue you are running into.

The directions ask you to print the result of comparing char with an empty space

If you write an empty string with no spaces like this "" that is not correct because it wants you to check for an actual empty space. So modify that string by adding a space to it.

Hope that clarifies

you are missing a space “print(char == ’ ')” as mentioned by jwilkins.oboe

if you have updated it, try to re run the code, may be hit run again might work

@petenddk @legacyofl2017 ,
Solution Removed
An empty space should be between the quotes in front of the char ==.
That’s the instruction.
The instructions says: At the top of your loop, print the result of comparing char with an EMPTY SPACE. Use the equality operator == for that.

Hi, welcome to the forum! Thanks for helping.

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.