At the top of your the loop, I replaced print(char == ’ ') with an if statement. The condition of this if statement should evaluate to True if char is an empty space and False otherwise.
Where is inside the if body in the line???
I put the string ‘space!’ and marks error. How do I indent this line???
WHAT IS TO INDENT???
Your code so far
# User Editable Region
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
'space!'
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/140.0.0.0 Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 41
the indentation is the spaces you add at the beginning of each line
the issue is not the indentation in this case, the issue is that you are not completely following the instructions. What do the instructions ask you to do with the string?
That 'space!' is just a string sitting there, it doesn’t do anything. You probably meant to print it. And since it’s inside the if, you need to indent it (with 4 spaces usually):
code removed by moderator
So:
Indentation = spaces at the start of the line.
Anything indented under if will only run if the condition is true.
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. How to Help Someone with Their Code Using the Socratic Method
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.
please do not use all caps, it is equivalent to screaming
as I already said, your indentation is fine, you are missing a part of the instructions as you have written a string on a line of it’s own and that does nothing, while you are asked to do something with that string