Learn String Manipulation by Building a Cipher - Step 41

Tell us what’s happening:

i am trying to print the result of char when comparing it if it is exactly equal to an empty string but it keeps showing me errors even if i write the variable after the for loop

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
char == ''
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 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 41

You need to use the equality operator == to compare char with a space ' '. You need to print this expression inside the loop.

i have also tried it, still gives me the same error.

Please share your updated code

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)

The comparison is now in the loop but giving the same error

ok, you have the comparison, but you are asked to do something with it

What does the error say?

Sorry, your code does not pass. Keep trying.

You should print the result of comparing char with a space inside your for loop

those are the two errors which i get after running the code

Read it, do you see any clues there?

Here is the instructions again:

***print*** the result of comparing char with a space (' ').

Read the errors, read the instructions.

—solution removed —

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.

1 Like