What's wrong? indentationerror


#1

My code is as follows:
The error says there is an indentationError in line 4. What is an indentation exactly? I haven’t really grasped that concept yet.

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

Thanks!


#2

indent refers to the amount of spacing at the beginning of the line, where many languages use curly brackets:

if (condition){
// code to execute
}

in python:

if condition:
    print "i need indent"

indent is used to determine nesting.

i would still indent in the first code sample for readability, but in python its mandatory given it determines nesting.


#3

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