Tried everything doesn’t seem to be working can someone tell me what’s the issue
Your code so far
# User Editable Region
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
if 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
Your browser information:
User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Mobile Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 41
Hello,
the problem is in this line if print('space!'): remove the if keyword along with the :
The original statement does not make sense because print('space!') does not evaluate to anything True or false, it just prints space in the console
At the top of your for loop, replace 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. Inside the if body, print the string 'space!' . Remember to indent this line.
For this step you need to remove the first line in the body of the for loop and replace it with an if statement - which you correctly implemented.
In the body of the if statement print the string mentioned in the instructions. You are not asked to add another if statement. To fix up your code remove the if keyword before the print call, and the colon after the print call.