Following code explain how 'global' works in the distinction of global variable and local variable.
var = 'Global Variable'
print(var) def func1():
var = 'Local Variable'
print(var) def func2():
print(var) def func3():
global var
print (var)
var = 'Global Variable Changed in Function' func1()
func2()
func3() print(var)
Expected Result:
Global Variable
Local Variable
Global Variable
Global Variable
Global Variable Changed in Function