Learn String Manipulation by Building a Cipher - Step 37

hey guys i am having trouble formatting this code any suggestion I have tryed several ways to format an di am falling behind

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
   if(char == '')else
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 (Windows NT 10.0; Win64; x64) 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

This is close, however:

'' #empty string
' ' #space character

Once you correct that, you just need to print() it, nothing else. I would reset the step and try it again.

At the top of your loop

This means the first thing after the beginning of the for loop

Are you sure that your comment is helpful?

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
(char == ' ')
print(' ')


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)

i just uploaded a update

soor i am halfway asleep heres another update

Hmm, the instructions want you to print something else:

At the top of your loop, print the result of comparing char with an empty space.

So I think there’s two issues here

  1. You should be inside of your loop, where char is defined

  2. You aren’t printing the result of the comparison

can i get another hint im having a hard time finding it

What did you try to change?

Did you try to fix these two points? Do you have questions about those two points?

its not int the loop :face_with_raised_eyebrow:

for char in text.lower():
    (char == ' ')
    print(' ')

Hmm, you still have the rest of the loop there, right? (just double checking). That’s the right location to put the new code now.

This still has the problem #2 - You compare the char to a string with a single space in it. Then you throw away that result and instead print a string with a single space in it. You need to print the comparison itself.

yeah i changed them from before the first time they where above for char in text.lower():

i never actually received the comparison and if i did i did not see anything i was looking for a result

I don’t know what you mean here?

right here you’re comparing the char to a string with a single space in it

If I coded this:

5 + 5

Maybe these get added, but you would never see any result. If you want to see the result, you print it.

print(5 + 5)

That’s how you print the result