Skip to content Skip to sidebar Skip to footer

How Do You Use Insert() In Python

myList = ['l','r','e'] myList.insert('x') I know that when using insert you need two arguments ,but what is the second argument I should pass?

Solution 1:

The first argument is the position to insert the element. The second argument is the element.

>>> myList = ["l", "r", "e"]
>>> myList.insert(0, "a")
['a', 'l', 'r', 'e']

Post a Comment for "How Do You Use Insert() In Python"