Adding Items by Position to a List in Python

We can also add elements to a specific position in the list. To do this, use the insert method. In its first parameter, we pass the desired position number (index). In the second parameter, we specify the element to be added:

pythonlst = ['a', 'b', 'c', 'd']
lst.insert(1, '2')

print(lst) # ['a', '2', 'b', 'c', 'd']
Задание 1

Given a list:

pythonlst = [1, 2, 3, 4, 5]

Add an element with a value after the two 'a'.

Задание 2

Given a list:

pythonlst = [1, 2, 3, 4, 5]

Add an element with a value to the beginning of the list 'a'.

Задание 3

Given a list:

pythonlst = [3, 6, 12]

Add 9 before the number 12 in the list.