For example:
x = {'a':1, 'b':2}
y = {}
# only requirement: x and y has to be parameters of function foo
def foo(x,y):
'''
How do I switch the two variables inside this function without scope issues?
'''
print('x =', x)
print('y =', y)
Result:
x = {}
y = {'a':1, 'b':2}
I tried putting global x, y
and putting x,y = y,x
inside the function but got this error as expected because they are already global:
SyntaxError: name 'x' is parameter and global
# Same thing happens for y