I tried fixing the indentation still didn’t work. the feedback I got feedback from someone on the forum and that didn’t help. I really don’t see the problem in my coding
Your code so far
# User Editable Region
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)
# User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 49
“all the following lines” means all of them, your for loop and everything after it is outside the function, while you should have everything inside the function
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.
Maybe this will help. This is what it looks like to format your code by indenting it into a function:
code = code
code
code
def function:
code
code
if this == that:
code
else:
code
code
code
code
EVERYTHING gets indented 4 more spaces. You were quite close before, you just missed some lines. The indentation needs to be exactly correct for every single line or it will not work.
indent all the following lines to give your new function a body.
Here I’ve indicated ALL the following lines. The last two print lines will also be part of the function and need to be indented.