Jun-06-2017, 03:58 PM
(Jun-06-2017, 01:01 PM)elhetch Wrote: i dont understand how this code works, as per my understanding every time the def function will be called , why it returns a result.
def rabbits(n): if n<1: return 0 else: if n==0 or n==1: return 1 else: return rabbits(n-1)+rabbits(n-2)-rabbits(n-5)
if n<1:overrides
if n == 0
Test everything in a Python shell (iPython, Azure Notebook, etc.)
- Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.