insertion in lists
Aloysio Figueiredo
xpythonist at yahoo.com.br
Wed Mar 3 14:50:20 EST 2004
I'm not sure if I understand your question, but I think you forgot
to make list[0] a list itself:
>>> element = 1 ## 1 or whatever
>>> list = []
>>> list.insert(0, [])
>>> list[0].insert(0, element)
>>> list[0][0]
1
Now, we have list[0][0] = element...
Aloysio
--- Lupe <luis_ at iname.com> escreveu:
> hi,
>
> I'm trying to have a kind of multi-dimensional list which seems to me
> to be
> the best way to have an array of not known extension, at the begining
> of
> the program.
>
> if I have:
> element
>
> list [0]
> and want to have list[0][0]
> list[0][1]
>
> how can I insert the element to that list[0][0], for example?
> just to put things clearer, if I wanted to insert the element in
> list[0] I
> could do list.insert(0,element).
>
> I've tried list[0].insert(0,element) but gives me an error.
>
>
> Luis
> --
> http://mail.python.org/mailman/listinfo/python-list
______________________________________________________________________
Yahoo! Mail - O melhor e-mail do Brasil! Abra sua conta agora:
http://br.yahoo.com/info/mail.html
More information about the Python-list
mailing list