The insert()
method inserts an element to the list at the specified index.
In this blog post, you will learn how to use the python list insert()
method.
Step 1: Create a list
my_list = [1, 2, 3, 4, 5]
Step 2: Insert into the list
my_list.insert(2, 34)
Step 3: Print the list
print(my_list)
Output:
[1, 2, 34, 3, 4, 5]