>
> >>> s = [1,2,3]
> >>> x = 5
> >>> s[len(s):len(s)] = [x]           # (1)



>
>>> s
 [1, 2, 3, 5]

When you did s[len(s):len(s)] you got the slice begining at len(s) with end
at len(s) - 1, ie, nothing.

At step (1), len(s) = 3, so you did s[3:3] = [x]. It meant that the slice
starting at index 3 (ie, just after s' end) is (now) the list [x].
When you did it again, you got slice s[4:4], which is empty.

[]'s


Douglas
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to