I seem not to be able to understand something fundamental. I have a function A
which calls function B
and proceeds with the results from it. Function B
on the other hand does some iterative calculations and gets called by other functions repeatedly until the iteration is satisfied. When the iteration is satisfied, what I want is one result for function A
(from function B
), but I seem to get as many results as function B
is iteratively called and my code just begins to act silly. It generally gives None
result.
Here is what I mean script-wise:
def func_A():
x = 1
y = 1
result_A = func_B(x, y)
print(result_A)
def func_B(x, y):
result_B = x + y
if result_B < 10:
func_C(x,y)
else:
return result_B
def func_C(x, y):
x = x + 1
y = y + 1
func_B(x,y)
func_A()
What I want is func_A
call to print 16
when x and y reach 4, however it returns None
. I have some complicated nest of functions so I need to solve this problem with this function structure. If anyone could help I would appreciate it very much.