Is there a better way of doing this?
__peter__ at web.de
Sat Mar 7 13:28:27 CET 2009
Lie Ryan wrote:
> mattia wrote:
>> Yes, sorry, I have to recycle! But how about this:
>>>>> rw = [[2,4], [4,5,6],[5,5]]
>>>>> rw += [[1,1]]*2
>> [[2, 4], [4, 5, 6], [5, 5], [1, 1], [1, 1]]
>> How can I recicle in this way using append?
> Not .append() but .extend()
Whether you use
items += [item]*N
is mostly a matter of style. You can avoid the intermediate list with
but I don't think this approach is faster.
More information about the Python-list