Describe your issue in detail here.
I don’t understand my mistake. Task says that: “The condition of this if statement should evaluate to True if char is an empty space and False otherwise. Inside the if body, print the string 'space!' . Remember to indent this line.”
Your code so far
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
print('space!')
index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index]
print('char:', char, 'encrypted text:', encrypted_text)
# User Editable Region
# 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/122.0.0.0 Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 42
it looks like you have a space after the colon here, it’s not a syntax error, but the tests have a few issues still that need to be fixed, please remove the space
yes, the space after the colon in the if statement is making so that the tests are not finding the if statement and the code that is inside (your print), so please remove the space after the colon
for char in text.lower():
if char==’ ':print(‘space!’)
index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index]
print(‘char:’, char, ‘encrypted text:’, encrypted_text)
Please open a new topic for your question, thanks!
If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.
The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.