def foo(x,y):
global a
a=42
x,y=y,x
b=33
b=17
c=100
print(a,b,x,y)
a,b,x,y=1,15,3,4
foo(17,4)
print(a,b,x,y)
- For foo(17,4), does global a means that a is a global variable for the entire program, even outside this funciton? And why does a=1 be modified to 42?
- For print(a,b,x,y), it doesn't call the function, so it should just prints global variables(defined outside the function), but why a is also changed to 42?