python - How to access a variable from one function in another -
i know may seem copy many other questions asked on stack overflow, didn't understand of questions. need clarify me, , please don't flag this. i'm running on python 3.4.2, windows 8.1
sample code:
def function_a(): my_name = "pamal mangat" return my_name def function_b(name): print("hello " + name) function_b(function_a.my_name)
you need call function_a()
way you're calling function_b()
; that's how return value. can't access variables inside function that; besides, exist while function running.
def function_a(): my_name = "pamal mangat" return my_name def function_b(name): print("hello " + name) function_b(function_a())
Comments
Post a Comment