S
Sibylle Koczian
Hello,
I thought I understood list slices, but I don't. I want to sort only the
last part of a list, preferably in place. If I do
ll isn't changed, because ll[2:] is a copy of the last part of the list,
and this copy is sorted, not the original list. Right so far?
But assignment to the slice:
_does_ change my original ll.
What did I misunderstand?
Thanks,
Sibylle
I thought I understood list slices, but I don't. I want to sort only the
last part of a list, preferably in place. If I do
[3, 1, 4, 2]>>> ll = [3, 1, 4, 2]
>>> ll[2:].sort()
>>> ll
ll isn't changed, because ll[2:] is a copy of the last part of the list,
and this copy is sorted, not the original list. Right so far?
But assignment to the slice:
[3, 1, 2, 4]>>> ll[2:] = [2, 4]
>>> ll
_does_ change my original ll.
What did I misunderstand?
Thanks,
Sibylle