"Review: Functions" Please help


#1

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.


#2

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' )
else:
    print('adult')

Functions

def functionname( parameters ):
   "function_docstring"
   function_suite
   return [expression]

And Classes

class Python(object):
    pass

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


#3

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

and not,


#4

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