How do I ignitalize a list please?

Kevin Cazabon kcazabon at
Wed May 3 06:51:16 CEST 2000

This is covered very well (as well as most other aspects of Python) in the
documentation, specifically the Tutorial.

However, in brief, you simply need to create the empty list first, as

list = []


for i in range(42):
    list.append(i * 42)

i[12] = "Eggs"



However, if you simply say that list=[], you cannot then assign to list[12]
because it doesn't exist yet.  You have to append X number of objects to the
list, or create the list with that many elements in the first place using a
"range" loop.

<cmfinlay at> wrote in message
news:kSUtN6=fLIxjJNG0pGTq25a0tuiY at
> How do I initialize a 'list' please?
> I read that a list is the only array that can be modified in standard
> python.
> (to put it simply)
> i = 1
> mags[0] = 0
> mags[1] = 1
> print mags[i]
> doesn't work.
> Please reply here
> or at cmfinlaySPAM at

More information about the Python-list mailing list