insert() – insert an list entry at the given index number

Code Explanation

LineDescription
1Declaration and initialization of the list myList with the values 1, 2, 3 and 5
3The insert() method adds a new element to the list by specifying its index.
5 + 6With the for loop each list element is output
myList = [1, 2, 3, 5]

myList.insert(3, 4)

for i in myList:
    print(i, end=" ")
Output
1 2 3 4 5