<Below this line, add a link to the exact exercise that you are stuck at.>
Oops, try again. Your code looks a bit off. Feel free to peek back at earlier exercises if you need a refresher! Your code threw the following error: ‘return’ outside function (python, line 4)
<What do you expect to happen instead?>
```python
def shut_down(s):
return message
if s == ‘yes’:
return “Shutting down”
elif s == ‘no’:
return “Shutdown aborted”
else:
return “Sorry”
<do not remove the three backticks above>
Hi try top remove the return message
you need to “tab” the ifs and the returns.
right now it seems that your function has only one instruction: return message.
Tab the other instructions to put them inside your function
i did that. Now its saying did you create a function called shut_down? And its already created
@tobuscus45 ,
def shut_down(s):
# return message
if s == 'yes':
return "Shutting down"
elif s == 'no':
return "Shutdown aborted"
else:
return "Sorry"
4 Likes
tunihi
March 14, 2016, 3:53pm
6
this code doesn’t work for me…
Hi can you post your code?
tunihi
March 14, 2016, 3:57pm
8
def shut_down(s):
if s == ‘yes’:
return “Shutting down”
elif s == ‘no’:
return “Shutdown aborted”
else:
return “Sorry”
with indentations
but it doesn’t put the indents on the post
1 Like
so its like that
def shut_down(s):
if s == 'yes':
return "Shutting down"
elif s == 'no':
return "Shutdown aborted"
else:
return "Sorry"
if so try to refresh the page. if that dont work , post the error you get
2 Likes
My code is below:
“”""
def shut_down(s):
if s==yes:
return “Shutting down”
elif s==no:
return “Shutdown aborted”
else:
return “Sorry”
return s
“”""
I get the error “Oops, try again. Did you create a function called shut_down?”
I have no idea what I’m doing wrong?
Hi you should add " "
around yes
and no
inside your if and elif condition
.
Wizmarco, thank you - that worked perfectly. Just so I understand, yes and no are considered strings for the s argument, correct?
1 Like
tunihi
March 16, 2016, 3:47pm
13
i figured it out, I was supposed to use “” instead of ‘’
1 Like
if’s should be indented once (tab or 4 space) returns should be indented 2 times.
def shut_down(s):
if s== ‘yes’:
return “Shutting down”
elif s==‘no’:
return “Shutdown aborted”
else :
return “Sorry”
def shut_down(s):
if s == ‘yes’:
return ‘Shutting down’
elif s == ‘no’:
return ‘Shutdown aborted’
else:
return ‘Sorry’
this worked for me
Im pretty sure all you need to do is remove return message this is my code
def shut_down(s):
if s == "yes":
return "Shutting down"
elif s == "no":
return "Shutdown Aborted"
else:
return "Sorry"
1 Like
I don’t understand what is wrong with my code, it throws the error "your function failed on the message yes. It returned ‘sorry’ when it should have returned ‘Shutting down’.
Can somebody help please?
def shut_down(s):
if s == “Yes”:
return “shutting down”
elif s == “no”:
return “Shutdown Aborted”
else:
return “sorry”
Hello!
I have a question.
I don`t know which part is incorrect and what does mean under message.
please help me.
Hi you should remove the returns s
def shut_down(s):
return s <== Remove this one
.........
Thank you!
I solved this problem thanks to you.
but I wonder the reason.
In the Review,
def speak(message):
return message
if happy():
speak(“Im happy!") elif sad(): speak(I
m sad.”)
else:
speak(“I dont know what I
m felling.”
What is the deffrence between review and my code?