Thursday, August 29, 2019

global key word usage in python

"""
Created on Thu Aug 29 16:29:56 2019
@author: anil durgam
date:29-08-2019
"""
f = 101;
print(f)
# Global vs.local variables in functions
def someFunction():
  global f
  print(f)
  f = "changing global variable"
someFunction()
print(f)


output:
101
101

changing global variable

No comments:

Post a Comment

python class topic video