[Tutor] Prepend to a list?

Sean Perry shaleh at speakeasy.net
Sat Mar 19 22:10:26 CET 2005


Jay Loden wrote:
> How can I prepend something to a list? I thought that I could do
> list.prepend()  since you can do list.append() but apparently not.  Any way to 
> add something to a list at the beginning, or do I just have to make a new 
> list? 
> 

 >>> a = []
>>> help(a.insert) 
     insert(...)
         L.insert(index, object) -- insert object before index


More information about the Tutor mailing list