Answers for "how to access a variable in another function in python"

2

how to access variable of one function in another function in python

def fun1():
    fun1.var = 100
    print(fun1.var)

def fun2():
    print(fun1.var)

fun1()
fun2()

print(fun1.var)
Posted by: Guest on May-31-2021
0

how to use variable from another function in python

>>> def oneFunction(lists):
        category=random.choice(list(lists.keys()))
        return random.choice(lists[category])


>>> def anotherFunction():
        for letter in oneFunction(lists):              
        print("_",end=" ")
Posted by: Guest on November-26-2020

Code answers related to "how to access a variable in another function in python"

Python Answers by Framework

Browse Popular Code Answers by Language