dumb newbie list question
Andrew Dalke
dalke at acm.org
Sun Aug 19 14:39:11 EDT 2001
Dan Girellini:
>>Is there an easy way to do this without building a
>> second list of the right size and concatenating them?
Bernd Nawothnig:
>Why will you do this?
>
>l=l+(10-len(l))*['x']
>
>works fine and should be faster then many l.append('x')
If you don't want to create a new list, you could also do
l.extend( [None] * (10-len(l)) )
(Using None is closer to the way Perl does it than using 'x'.)
Andrew
More information about the Python-list
mailing list