Adding item in front of a list
Andrew Koenig
ark at research.att.com
Wed Apr 9 10:37:36 EDT 2003
Thomas> Hi!
Thomas> I think it would be nice if
Thomas> l=[2, 3, 4]
Thomas> l.insert(1)
Thomas> would insert in front of the list, as opposed to append()
Thomas> which adds new elements at the end.
Thomas> l.insert(1) looks better than l.insert(-1,1)
So does l.insert(0, 1) :-)
I would have thought that after l.insert(-1, 1), l would be
[2, 3, 1, 4], but it doesn't work that way.
--
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark
More information about the Python-list
mailing list