Global variable is python


'''l=10#global
def fun1():
    #l=5#local
    m=8#local
    #it through error beacuse not have permision if it change so take global keyword
    global l
    l=l+45
    print(l)
fun1()
'''
x=90
def deep():
    x=20
    def rohan():
        global x
        x = 88
    print("before calling rohan()",x)
    rohan()
    print("after calling rohan()",x)

deep()
print(x)

 

Comments

Popular posts from this blog

Become Healthy Goal - Python Program

Calculator in C++

Interpretation vs Compilation