[Tutor] s[len(s):len(s)] = [x] ??
Dick Moores
rdm at rcblue.com
Sat Jun 28 03:02:33 CEST 2008
I'm very familiar with appending x to a list, s, using s.append(x),
however, I've never understood what the docs mean by
s.append(x) same as s[len(s):len(s)] = [x]
(See <http://docs.python.org/lib/typesseq-mutable.html>)
Trying it,
>>> s = [1,2,3]
>>> x = 5
>>> s[len(s):len(s)] = [x]
>>> s[len(s):len(s)]
[]
>>>
I'm not enlightened. Just what do the docs mean?
Thanks,
Dick Moores
More information about the Tutor
mailing list