Mega Code Archive

 
Categories / Python Tutorial / Function
 

Variable Scope in Functions

x = 10 def func() :     x = 20     print "in function func, x = ", x def gfunc() :     global x     x = 20 print "in function gfunc, x = ", x print "Initially, x = ", x func() print "After func, x = ", x gfunc() print "After gfunc, x = ", x