Learn String Manipulation by Building a Cipher - Step 41

Tell us what’s happening:

I am not sure what this question is asking me to do. I know it wants me to compare [char] and set that equal to a blank quote so I have tried to add → char == (’ ‘) <-.
From there I tried to
print(’ ') and print(" ") and print (char)

when I plugged this into chatgpt this is the code it gave me

for char in text.lower():
# Check if the character is a space
is_space = char == ’ ’
print(‘char:’, char, ‘is space:’, is_space)

and the program still told me that this was incorrect.

# Perform other operations based on the challenge prompt

Your code so far


# User Editable Region

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

for char in text.lower():
    result = (char == ' ')
        print(result)
    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 41

Hi there. You really should not use ChatGPT when trying to learn how to code for several reasons. The biggest one is you deprive useful of a good learning opportunity.

Secondly your Python code shouldn’t be working in the challenge to begin with because of this formatting issue.

result = (char == ' ')
        print(result)

Once print has the same indentation as the rest of your code, maybe try directly printing the result into the console instead of saving it into a variable. While it is generally nice to store things in variables, here it isn’t required.

Hope this helps. :slight_smile: