Use the insert method for the list:
l = list(...) l.insert(index, item)
Alternatively, you can use fragment notation:
l[index:index] = [item]
If you want to move an element that is already in the list to the specified position, you will need to delete it and insert it into a new position:
l.insert(newindex, l.pop(oldindex))
David Z Jul 03 '10 at 23:15 2010-07-03 23:15
source share