Anvit Garg Anvit Garg - 2 years ago 118
Python Question

Program Returning nothing

I saw this Flowchart and decided to make a program out of it. The problem is, it only returns "Go Outside" if I enter "no" the first time. All others return "None". Im using Python 2.7

def waitawhile():
print "Wait a while"
rain2 = raw_input("Is it still raining?")
if rain2.lower() == "no":
return "Go Outside"
elif rain2.lower() == "yes":
def Raining():
print "Is it raining?"
rain = raw_input()
if rain.lower() == "no":
return "Go Outside"
elif rain.lower() == "yes":
print "Have Umbrella?"
umbrella = raw_input()
if umbrella.lower == "yes":
return "Go Outside"
elif umbrella.lower() == "no":
print Raining()

Answer Source

The problem is with your calls to waitawhile (from both Raining and from waitawhile itself). After calling it, you're discarding the return value and returning nothing. To fix it, change the calls from:



return waitawhile()

Make sure that, for both functions, there is no way to reach the end of the function without executing a return statement.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download