Hi.
The explanation on that page may be a bit confusing, so I will add to it.
If you think of L * n as something similiar to doing a shallow copy of
the list L n times, then it makes some sense:
>>> a = []
>>> L = [[]]
>>> for i in xrange(5):
... a.append(L[:][0])
has the same (or similia
Yang wrote:
> So, can somebody tell me how the * operator of list and tuple work,
> and how can we make use of it?
A bit more here:
http://docs.python.org/lib/typesseq.html
See especially note (2)
Kent
___
Tutor maillist - Tutor@python.org
http://mai
tutor-request:
I found this interesting question in a local forum,
and want to get a more detail explain of it:
>>> a = [[]]*5
>>> a
[[], [], [], [], []]
>>> a[0].append(3)
>>> a
[[3], [3], [3], [3], [3]]
>>> b = [[] for i in range(5)]
>>> b
[[], [], [], [], []]
>>> b[0].append(3)
>>> b
[[3], []