Comparison operators allow you to compare two objects based on their values. You can use a comparison operator by placing it between the objects you want to compare. They return a Boolean value — namely True or False — depending on the truthfulness of the expression.
Python has the following comparison operators:
Operator Meaning
== Equal
!= Not equal
Greater than
< Less than
≥ Greater than or equal to
≤ Less than or equal to
At the top of your loop, print the result of comparing char with an empty space. Use the equality operator == for that.
Your code so far
/* User Editable Region */
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
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; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 37
Sorry I forgot to include a question. It asked me to compare char in the loop to a blank space but when I submit, it seems to not be what they want. I tried putting puting single quotes and leaving it blank but it didn’t work. My final attempt is what you see in the first line of the loop where (char == ). I’m not really sure what to do
You want to print that to the console, but if you think about it, you are trying to compare char to something, so rethink and ask “what goes on the right side of that comparison statement?” For example, if I want to check if char is equal to the letter ‘a’, I can do something like the following:
char == 'a'
But that does not help because you cannot see the result of the comparison, can you? To view the result of the comparison, you need to print it out by wrapping that in a print function, like so:
print(char == 'a')
Now, instead of comparing it to ‘a’, think about “how to represent an empty space in python?”, and replace ‘a’ with how an empty space in Python is represented. I believe this should help. If not, reply back to this.
You can post solutions that invite discussion (like asking how the solution works, or asking about certain parts of the solution). But please don’t just post your solution for the sake of sharing it.
If you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.
[ilenia] Consider it done! I will not post the entire solution. I will just post hints, suggestions etc. and if I post code with questions I will follow your guidelines as, I don’t want to ruin the challenge for others. I like the idea of adding [spoiler] and [/spoiler] tags on the line above and below the solution code. Including you, I want to be in everyone’s good books here .
What you’ve written is correct for an empty string
If you have more questions about this Step can you please open a new topic?
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.