When passing a list as an argument in function why the following list is not changed ?
def foo(*x):
y=sorted(x)
print(y)
a=[3,2,1]
[[3, 2, 1]]
[[1,2,3]]
Why creating another function? You can just do this
>>> a = [3,2,1]
>>> sorted(a)
[1, 2, 3]
However if you want to create another function. You have to call it.
def foo(x):
y=sorted(x)
return y
a = [3,2,1]
print(foo(a))