17. Review: Function


#1

This is my code

def shut_down(s):

if s or "yes":
return "Shutting down"
elif s == "no":
return "Shutdown aborted"
else:
return "sorry"

and it threw the error

File "python", line 3
if s or "yes":
^
Indentation Error: expected an indented block

> Someone please help me


#2

Instead of "or" it should be == , as it is equal too. Hope this helps!


#3

Please tell me if this helps, as this is my first comment!


#4

sorry but it didn't really help. i still got the same thing


Functions.17: some one plz tell me what I'm doing wrong
#5

well you made two errors, the first was writing:

if s or "yes"

as you want to the function to return "shutting down" when the variable 's' is equal to 'yes'.
However, to solve your error message, you need to add some indents to your code. It should look like:

def shut_down(s)
    if s == "yes":
       return "shutting down"
   elif s == "no":

etc.


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.