17/19 Why isn't my code working?



When I submit the code it just says "Line 6:Invalid Syntax"

Code below-

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


Hello @arva2121
This program have indentation problem.
We need to fix the indentation here,

Indentation is used to define different code blocks.
When we define a function, conditional clause , Loops, we actually define different blocks of code.

When one block of code resides inside of another, we need to space out internal block by some spaces,

Like here, inside the function block, We have conditional clause, so we need to indent it using four spaces, also the code lines inside the if/elif/else need to be indented by 4 spaces.

We can use this template..

def someFunction(some parameter):
    if test:
    elif test:
    elif test:


What have you learned so far with respect to Python syntax and the need for consistent indentation of code blocks? Are you aware of the importance of this to context and scoping?


Thanks! When I asked the question it wasn't indented. Now it works!


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