Review: Functions


#1

    return "shut_down"
if     s == "yes":
    return "Shoutdown aborted"
else:
    return "Sorry"

I have no idea what is wrong with my code...Please help


#2

Indent your code properly..like this..

def some_function():
    if condition1:
        # your code.
    elif condition2:
       # your code
    else: 
        # your code

4 spaces!


#3

Thx, the issue is now on line 2 but I don't know how to fix it. something is wrong with the return


#4

Can you post your code?


#5

if shut_down("yes"):
return "shut_down"
if s == "yes":
return "Shoutdown aborted"
else:
return "Sorry"


#6

if shut_down("yes"):

you have to compare s with 'yes' ,

if (here your condition) :


#7

oh okay thx!!! I really hope that it work


#8

if shut_down("yes"):
return "shut_down"
if shut_down("yes"):
return "Shutdown aborted"
else:
return "Sorry"
I'm not sure if I did it right... it still says that something is wrong with the line 2 return


#9

I knew It was coming..
your next branch should be elif with condition of comparing s with 'no'!


#10

You have two if statements just so you know.


#11

how do I do that??? I have not coded in a while and came back to this haha


#12

can you see my first post ?in same format!
i.e is..

def some_function():
    if condition1:
        # your code.
    elif condition2:
       # your code
    else: 
        # your code

#13

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