Help for review:function


#1


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


https://www.codecademy.com/courses/python-beginner-c7VZg/4/1?curriculum_id=4f89dab3d788890003000096#

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"
    
else:
    return "Sorry"


#2

Indent your code properly..

Like syntax given below..

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

#3

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


#4

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"
else:
print("Sorry")


#5

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 ?


#6

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