Can anyone please help me understand what's happening with the scoping in fun1() and fun2(). Naively, I expect both to modify x in-place.
def fun1(t):
t = t + [2]
def fun2(t):
t += [2]
x = [1]
fun1(x)
print(x) # output is [1] (I expected [1,2])
x = [1]
fun2(x)
print(x) # output is [1,2] (as expected)