I have a variable "x
" assigned to a function ("rundown
"). Inside of that function, two variables "y,z
" are reduced by a random value. Conditional statements then check if both y and z are still greater than 0 - if so, the function runs again with the new values, repeating until one variable hits 0.
Once one of these variables hits 0 or less, the function is supposed to return a value based on whether y
or z
hit 0 first. x
is supposed to be assigned that value so conditionals in the main function can be based off the result of the rundown function. But that part doesn't seem to be working.
I've tried adding print statements to the conditionals just to see if they trigger, and they do. But when I add a print statement to x
, it just prints "none" so I know that's where my code is breaking. I'm just not sure why... Here's the jist of what I'm working with:
def main():
x = rundown(y,z)
if x == 0:
#(do something)
elif x == 1:
#(do something else)
def rundown(y,z):
y -= (1 + random.random())
z -= (1 + random.random())
if y <= 0:
return(0)
elif z <= 0:
return(1)
else:
rundown(y,z)