Recursive function returns None, when True is expected - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Recursive function returns None, when True is expected (/thread-29527.html) |
Recursive function returns None, when True is expected - akar - Sep-07-2020 Hi, I'm learning Python, I guess this must be absolutely silly but it's been driving me mad for hours. I've simplified a lot from the original problem, and I can't understand how this function returns None in many cases: def funk(a, b): print(a, b) if a == (b * 0.10): print('flag') return True elif a > 0.25: a -= 0.25 b -= 1 funk(a, b) else: return FalseFor example with a = 1.25 and b = 8, the output is: It displays 'flag' but eventually returns None and not True as I would expect.However, it returns True for other values like a = 1 and b = 10. I've made other tests and could never get it returning False. Why? Thanks for any help to figure it out. Eventually I've found the solution... line 9: return funk(a, b)Sorry for inconvenience... |