Learn String Manipulation by Building a Cipher - Step 37

Not sure if I’m missing a detail, but I’m getting the false in the console, but my code isn’t passing. I’ve tested other combinations and have gotten true as well. I also have tried ’ ’ vs " " swapping the placements of char at the front of == and behind. I’ve also added a space.

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

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

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

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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 37

“At the top of your loop”, means on the first line inside the loop. That is how you have access to char because char is a variable inside the loop.

char is expected to be on the left-hand side of the comparison operator ==

lefthand === righthand

thank you for the reply. I’ve tested it out before using the following:

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)

I can see the false line repeating, but it is still not passing.
also spaces are coming over into the forum, but I have space for char == " "

char is a variable not a string.

1 Like

ACCK! Thank you, I feel like a Goober >_<

1 Like

Coding will do that to you.

Anyway, it is a pretty common mistake to make in the beginning. Keep going and happy coding.