I am unable to figure this out because the topics related to my problem only give the instruction
my problem isn’t following the instruction i understand it actually but i dont know what calling a function really is
i get thath i have to write at the bottom of the already existing code but what do I write?
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 47
in the instruction syntax for function call is given. also u have been instructed to call function caesar . follow the syntax. replace function_name with caesar and put (). u should call u function outside function definition.
this set is function definition. u have to call function after this. call function
u see here def starts. like wise call the function at end where def started.
aaronvincent6411 is right just be careful with indentations. So no indentation when calling function at the end. Everything inside the def caesar(): should have one indentation plus the indentation they would normally would’ve. I don’t think anything is wrong with your code except for indentations. Just make sure when you are calling your caesar function, don’t use any indentation.
I hope you get it right! Because not gonna lie, I was stuck on this question too!
i would have to apologize to you guys the reason why it wasn’t working was because when i tried to call function_name as caesar i spelt it " CAESER " instead of the actual word “CAESAR”
the A at the end actually was the problem
Great! Sometimes you really can’t notice different when so much thing is going on your mind, so it is good to just leave it and come back with a fresh mind! Glad you solve the problem