Simple list.append() question

Fredrik Lundh effbot at telia.com
Tue Apr 25 03:56:01 EDT 2000


#VEDALA NARASIMHA KUMAR# <PA0215481 at ntu.edu.sg> wrote:
> l=[]
> i=0
> while 1:
>     if i <3:
>         l.append([])
>     else:
>        break
>     i=i+1
>
>  crude..but works

tip: using for-in and range is faster, easier
to read, and definitely more "pythonish":

    l = []
    for i in range(3):
        l.append([])

</F>





More information about the Python-list mailing list