If x is list say
x = [1,5,6,4]
now
you want to store the sorted list in y, it is intuitive to do
y = x.sort()
But, x.sort() returns null but you can do
y = x[:]
This copies all elements to y
y = x
would just point the reference so if you sort y now, x would also be sorted.
No comments:
Post a Comment