append will add an item to the end of the list.
l = [1,2,3,4]
l.append(5)
outputs
[1, 2, 3, 4, 5]
now instead of adding 5 at the end of the list I would like to add it to a random location in the list. let's say 5 is being added to index 2. Number 3 will move one index forward.
[1,2,5,3,4]
Aucun commentaire:
Enregistrer un commentaire