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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -