Python list type is used to store multiple items in a single object. The items can be put during list creation or added later by using the insert()
method. The insert() method adds items to the specified index number. This means insert() method does not directly add a new item at the end of the list.
List insert() Method Syntax
The syntax of the List insert() method is like below. The insert() method does not returns a value and only changes the list by adding a specified item to the specified index.
LIST.insert(INDEX,ITEM)
- LIST is the list where a new ITEM is inserted.
- INDEX is the index number for the LIST where the ITEM is put.
- ITEM is the element that is inserted into the LIST.
Insert Item To The Specified Index In List
The insert() method is used to insert the specific item to the specified index in the list. The index numbers start from 0 in the list. In the following example, we insert the “Ankara” into index number 2 which is 3rd item.
cities = ["London","Berlin","Paris","Amsterdam"]
cities.insert(2,"Ankara")
print(cities)
['London', 'Berlin', 'Ankara', 'Paris', 'Amsterdam']

Insert Item Start Of The List
As we can specify the index number to insert an item we can insert the item to the start of the list by using the index number 0. The index number 0 specifies the start of the list.
cities = ["London","Berlin","Paris","Amsterdam"]
cities.insert(0,"Ankara")
print(cities)
['Ankara', 'London', 'Berlin', 'Paris', 'Amsterdam']
Insert Item End Of The List
The insert() method can be also used to add a new item at the end of the list. The len()
function is used to specify the last index which is also the end of the list. Below we add the new item at the end of the list.
cities = ["London","Berlin","Paris","Amsterdam"]
cities.insert(len(cities),"Ankara")
print(cities)