Python Review: Functions Help


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


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


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.


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


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


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


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


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


@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: