You can add an element at the specified position in a list in Python by following the given step. If you want to learn Python then I will highly recommend you to read This Book.
Step 1
Insert method is used to add an element at the specified position in a list in Python. In the following example, I will insert integer ’11’ at position 3 in the list.
a = [1,2,3,4,5,6,7,8,9,10] print(a) a.insert(3,11) print(a)
Example: In case of string
a = [20,31,55,75,80,47] print(a) a.insert(1,'AI Hints') print(a)
People are also reading:
What is Computer Vision? Examples, Applications, Techniques