dumb newbie list question

Bernd Nawothnig Bernd.Nawothnig at t-online.de
Sun Aug 19 20:24:46 EDT 2001


Hallo Dan!

On 19 Aug 2001 18:45:21 -0400, Dan Girellini <drg at longhands.org> wrote:

>  Maybe this is a naive/stupid question, but is there anyway to grow a list to an
>  arbitrary size?  Eg.:

>>>> l = [1, 2, 3]
>>>> l[5] = "x"

>  won't work (obviously).  Is there an easy way to do this without building a
>  second list of the right size and concatenating them?  

Why will you do this?

l=l+(10-len(l))*['x']

works fine and should be faster then many l.append('x')

>  I'm trying to drop my perl habits when using python, really!

You should choose the best solution - may it come from perl or any other
language. 




Bernd



More information about the Python-list mailing list