Hello there, pls i need some help, it keep raising the error message that i need to use the def keyword to define a function but it looks like i followed the steps exactly as it was given
my code:
text = 'Hello Zaira'
shift = 3
def caesar():
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
encrypted_text += char
else:
index = alphabet.find(char)
new_index = (index + shift) % len(alphabet)
encrypted_text += alphabet[new_index]
print('plain text:', text)
print('encrypted text:', encrypted_text)
Please post a link to the Step. Thanks
Careful with your indentation. Indentation is syntax in Python and so vitally important.
Everything here has different/incorrect indentations.
Clean that up and see what you get.

pls take a look at it again
I have indented the lines to the best of my knowledge, i still get the error message, pls tell me what i am doing wrong
a brief on my thought process here is i have indented the whole lines after the defined function , however i have indented the lines after the for loop and then at the print call i have moved out to join the outer indentation to ensure my print is on one line.
so please tell me what i have done wrong here?
i suspect it might be something else because i can’t say its the def function syntax because it looks good to me however the error message still points to that
I can’t look at your code, I copied it from here and into the editor to examine it. You can copy/paste your updated code here though and I’ll take a look.
The hints aren’t always accurate bc it’s hard to account for every possible error. You can open the console (button on the upper left) which might give you more clues.
i have gotten it finally, thanks
1 Like
what did you do differently, I am stuck?
Please open a new topic and share your code, 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.
Thank you.