"Review: Functions" Please help


def shut_down(s) :
return shut_down
if yes():
return "Shutting Down"

elif no():
    return "Shutdown aborted"

 else :
     return "sorry"

Is returning "IndentationError: unindent does not match any outer indentation level" Please Explain.


In Python, Indentation is used to group blocks of code that are related to each other. The Python operator that indents code is the colon ( : ). Any code after a colon is indented by four spaces. Examples of when indentation is used,

if/elif/else statements,

age = int(input('How old are you? '))
if age <= 2:
    print(' baby')
elif 2 < age < 13:
    print(' child' )


def functionname( parameters ):
   return [expression]

And Classes

class Python(object):

Note: All code after the colon is indented by four spaces, any code on the same indentation level will be grouped after the colon.

When your code is badly indented you will receive this error,

IndentationError: unindent does not match any outer indentation level


Also you are supposed to be checking if s your argument is equal to a string"yes" or "no"

and not,


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