3 ms·
You can explicitly reference a global variable if you want this behavior: def f_global(): global s s = "Me too." print(s) prin
by kevinmgranger 5y ago
You can explicitly reference a global variable if you want this behavior:
def f_global():
global s
s = "Me too."
print(s)
print(s)
f_global()
print(s)
Will print:
I love Geeksforgeeks
Me too.
Me too.
Of course... please don't do global mutable variables.