Answers for "accessing a variable from outside the function in python"

0

accessing a variable from outside the function in python

# for accessing a variable from outside the function then create that variable
# as an attribute of the function
def hi():
    # other code...
    hi.bye = 42  # Create function attribute.
    sigh = 10

hi()
print(hi.bye)  # -> 42
Posted by: Guest on December-29-2020

Code answers related to "accessing a variable from outside the function in python"

Python Answers by Framework

Browse Popular Code Answers by Language