How to recall a previous definition from another definition Python 3 -


this question has answer here:

i want know if defining function can related function, it's chain reaction. following formulas, want print final value, 15.

how should change 'second_formula' recognize value 'c' 'first_formula', , on.

def first_formula():     = 1     b = 2     c = + b     second_formula()  def second_formula():     d = 4     e = c + d     third_formula()  def third_formula():     f = 8     g = e + f     print (g)   first_formula() 

pass parameter.

def first_formula():     = 1     b = 2     c = + b     second_formula(c)  def second_formula(c):     d = 4     e = c + d     third_formula(e)  def third_formula(e):     f = 8     g = e + f     print (g)  first_formula() 

however, better if you'd have each function return result; let calling program decide should go:

def first_formula():     = 1     b = 2     return a+b  def second_formula():     d = 4     return d + first_formula()  def third_formula():     f = 8     return f + second_formula()  print(third_formula()) 

does help?


Comments