[Tutor] Insert elements in a lis

Alan Gauld alan.gauld at blueyonder.co.uk
Wed Aug 11 08:45:38 CEST 2004


 
> > >>> print [1,3,5].insert(1,2)
> > [1,2,3,5]
> 
> What Python version is that?  I get None (since insert modifies the
> list in-place and doesn't return the list) in Pythons 2.1, 2.2 and
> 2.3.

Rats! You caught me!
I actually did:

>>> L = [1,3,5].insert(11,2)
>>> print L

And in the email "abbreviated" it, but forgot that insert doesn't 
actually return the new list - oops!

Alan G.


More information about the Tutor mailing list