array, list, performance...
gabor
gabor at realtime.sk
Thu Jun 6 16:40:26 EDT 2002
On Thu, 2002-06-06 at 10:20, Steve Holden wrote:
> "Christopher Armstrong" <radix at twistedmatrix.com> wrote in message
> news:mailman.1023373030.31871.python-list at python.org...
> >
> > > Michael Chermside <mcherm at destiny.com> writes::
> > > li[n] = x assignment to the middle is O(len(li))
> >
> > This doesn't seem right. Shouldn't that be O(1), just like
> > access-time?
> >sorry, but i don't understand...
how can you use li[n] = x to INSERT an element into a list..
IndexError: list assignment index out of range
as far as i know:
if n<len(li) then it overwrites the existing value.
else you get an "IndexError: list assignment index out of range".
am i wrong?
thanks,
gabor
More information about the Python-list
mailing list