Jul-20-2019, 04:28 AM
Hi,
I need a little help understanding python recursive functions. My function stops at an integer instead of returning a bool like I want it to.
At least, that's my intent. I don't understand what I'm doing wrong.
I need a little help understanding python recursive functions. My function stops at an integer instead of returning a bool like I want it to.
def time(attack, calm, worker): #2, 3, 9 goes in if worker - attack <= 0: #will 9 - 2 = 0 or less? return False else: worker = worker - attack #Stops here at 2. I know because I printed worker here in the function if worker - calm <= 0: # 2 - 3 would be negative 1, so it should return true right? return True else: worker = worker - calm time(attack, calm, worker) # recursive calls9 would become 7, then 4, then 2, then trying to subtract 3 would make it return a boolean.
At least, that's my intent. I don't understand what I'm doing wrong.