<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">>>> s = [1,2,3]<br>
>>> x = 5<br>
>>> s[len(s):len(s)] = [x] # (1)</blockquote><div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"></blockquote><br>
>>> s<br> [1, 2, 3, 5]<br></div><br>When you did s[len(s):len(s)] you got the slice begining at len(s) with end at len(s) - 1, ie, nothing.<br><br>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].<br>
When you did it again, you got slice s[4:4], which is empty.<br><br>[]'s<br><br><br>Douglas<br><br>