def f(x):
x = x[::-1]
list = [1,2,3]
f(list)
print(list)
OUTPUT: [1,2,3]
Can someone explain why the list didn't reverse? In the next example it reverses, but why? I can't really understand this behavior.
def f(x):
x[:] = x[::-1]
list = [1,2,3]
f(list)
print(list)
OUTPUT: [3,2,1]