[Tutor] Insert elements in a lis

Kalle Svensson kalle at lysator.liu.se
Wed Aug 11 00:06:37 CEST 2004


[Alan Gauld]
> > Is it possible to insert elements in a list in an easy way?
> 
> >>> 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.

Peace,
  Kalle
-- 
http://juckapan.org/~kalle/
http://laxmasteriet.se/04-05/


More information about the Tutor mailing list