Python Review: Functions Help


#1


Please explain your answer fully , I need as much help as i can get , Thanks.


#2

you'r indents are off, indents are important in python. Why do you use (s) in if?


#3

I have changed the (s)'s to shutdown , It is the argument inside shut_down(s) , I have re-written the code , It still tells me the same exact thing.


#4

check return on google, once you return something in your function, your function stops, its not executing anything after return, so you need to remove that first return


#5

now you actually made matters worse, if (s) == "Yes", was fine, except for some reason you used brackets where not needed:

if s == "Yes":

i would put return "Shutting Down" inside your if block, where you currently have return s. Also, your if statement is not inside the function, in this code if is outside the function:

def test_function():
   print "if outside the function"
if (True):
   print "the if statement is outside the function"

the if statement inside the function:

def test_function():
   if (True):
      print "the if statement is inside the function"

your if/elif/else block should be inside the function, make sure the indention is good


#6

It didn't work , However tried the other guy's advice and it worked , Thank's anyway.


#7

Hmm , It worked! Thank's alot man! I really appreciate it!


#8

I was not giving you the answer, just tried to explain you the return, its important to understand what you do


#9

@absoluteprogrammer13, it is important to understand return. A function ends, the moment a return keyword is reached, in your case the first line of the function:

return shutdown

you might want to remove it. Since now, when you call the function:

pint shutdown("Yes")

the wrong thing gets returned :frowning: