17.Review : Functions


#1



I think code is right,but i get this message : File "python", line 3
if s == "yes":
^
IndentationError: expected an indented block.
I tried everything.Refreshing adding "return message" on top etc...
This is my code


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


#2

error is straight forward
IndentationError: expected an indented block.

indent body of your function


#3

What in the name of God do you mean?


#4

Indent is basic knowledge of python

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

#5

currently, if/elise and else is outside the function:

def example():
if condition:
    /* if condition outside the function */

you want to change the indent, so the if statement is inside the function:

def example():
    if condition:
        /* if condition outside the function */

#6

Yes you were right.BTW i know it as whitespace.Thanks.Didnt know if should be inented too


#7

Yes thanks vary much


#8

A post was merged into an existing topic: 17. review functions


#9

2 posts were split to a new topic: 17. review functions