You can use list.insert(i, x)
, where:
list
is the name of the list,i
is the index of the element before which to insert, andx
is the value to be inserted.
In your case, it should be:
l.insert(0,x)
solved How to move all the elements in a list, a step forward in python?