Review: Functions


#1



def shut_down(s):

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


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

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:
expected an indented block (python, line 3)


What is the error in this?


Replace this line with your code.


#2

the whole if/elif/else code block should be inside the function, currently your function is empty:

def example_function():
   print "i am inside the function"
print "i am outside the function"

you might want to re-indent your code, so that if/elif/else is inside the function (see my example above if you need help)


#3

Python is a stickler when it comes to indentation. You need to indent if statement and then indent return some more like this:

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


#4

2 posts were split to a new topic: Reveiw functions


#5

A post was split to a new topic: Review: functions


#6