Learn String Manipulation by Building a Cipher - Step 37

Tell us what’s happening:

I am not completely sure on what I am doing wrong. the ’ ’ and " " should be about the same right?
line 7

Your code so far


/* User Editable Region */

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

for char in text.lower(): 
    print(char ==" ") # Does it matter if I use ' ' or " "
    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:121.0) Gecko/20100101 Firefox/121.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 37

@Swaggart
(‘’) and (“”) are about the same. you are ask to compare char with empty space not empty string . You can achieve that by hitting the space key. so you have something like ’ ’ not ‘’

so should it be print(char== ) I am confused if I am calling char wrong, or if my syntax is off. Line #7 is where I am having the problem right?

Hello Swaggart,

Your code is fine, I assume there is something wrong with the indentation. I would advise to reset the code and put the print line back and see if it passes then.

text = ‘Hello World’
shift = 3
alphabet = ‘abcdefghijklmnopqrstuvwxyz’
encrypted_text = ‘’

for char in text.lower():
print(char==()) still didnt work
index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index]
print(‘char:’, char, ‘encrypted text:’, encrypted_text)

Hello Unimke,

It would be much easier to help you if you made your own topic. You can do so in the step where your code is by clicking on “Help” and then on “Create a help post on the forum”.

But anyway, from what you posted above, it seems like you are now comparing char with () not with an empty space. Remember an empty space is also a character, for example if you wanted the character a you would use 'a', the same logic is used for the space character.

Does that start me from scratch? I went back a few steps and worked back up, reloaded the page still won’t let me pass

Yeah it would. It may help in cases where things seem to be fine but they still don’t pass.

Thank you for your quick response! ill give it a go

1 Like