Help for review:function


what is the wrong in this code ? i searched it from the blog,i used all suggestions but still doenst work.İ dont know what the problem is

File "python", line 3
if s == "yes" :
IndentationError: expected an indented block

def shut_down(s):
if s == "yes" :
    return "Shutting down"
elif s == "no" :
    return "Shutdown aborted"
    return "Sorry"


Indent your code properly..

Like syntax given below..

def Anyfunction():
    if condition1:
        #your code
    elif condition2:
        #your code
       #your code


thankkk youuu so much ! it worked, i didnt notice the returns' places are wrong...


Oops, try again. Make sure you are returning the answer for shut_down("maybe") and not printing it!

why it is showing in my code.......

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


They have explicitly told in instruction ..If you notice then you will get the cause of error...

1.First, def a function, shut_down, that takes one argument s. Don't forget the parentheses or the colon!
You did it

2.Then, if the shut_down function receives an s equal to "yes", it should return "Shutting down"
You did it

3.Alternatively, elif s is equal to "no", then the function should return "Shutdown aborted".
You did it

4.Finally, if shut_down gets anything other than those inputs, the function should return "Sorry"
have you done this part ?


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