Sep-07-2020, 07:58 PM
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:
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:
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:
Output:1.25 8
1.0 7
0.75 6
0.5 5
flag
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...