Review Functions


#1

IM DONE
I tried everyting i can find...
and now I have this:

https://www.codecademy.com/courses/python-beginner-c7VZg/4/1?curriculum_id=4f89dab3d788890003000096#

def shut_down(s):

if s == "yes" :
return "Shutting down"
elif s == "no" :
return "Shutdown aborted"
else:
return "Sorry"

shut_down ("no")

???????????????????????????????????????????????????????????????????????

Oops, try again. Your code looks a bit off. Feel free to peek back at earlier exercises if you need a refresher! Your code threw the following error: expected an indented block (python, line 3)

File "python", line 3
if s == "yes" :
^
IndentationError: expected an indented block

Someone help me


#2

Look at the error. You need to indent your code. That includes under your function and under your statements.


#3

def shut_down(s):
    
        if s == "yes":
            return "shutting down"
        elif s == "no":
            return "shutdown aborted"
        else:
            return "sorry"
            s == "yes"
        return s

Look at correct code formatting when asking a question, it makes it easier to read.

In a function you have:

def function(argument):
    indent
        indent again

and so on


#6

It worked for me. Check the code below

def shut_down(s):

if s == "yes":
   return "Shutting down"

elif s == "no":
   return "Shutdown aborted"
   
else :
    return "sorry"

#7

I’m having the exact same problem. I’ve indented it several different ways and it still wouldn’t work. I finally just did this:
def shut_down(s):

	if s == "yes":return "Shutting down"		

	elif s == "no":return "Shutdown aborted"
	
	else:return "Sorry"

This made it work. I don’t think this would work usually?? Any thoughts anyone?


#8

If it helps any, I’ve just had big problems with the ‘Indentation Error’ problem.
It turns out using the TAB key didn’t put the indents in exactly the right place!

A TAB and a SPACE was needed for the “return” statements…

I can laugh about it now!!!


#9

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