0 votes
in Python by
How can you insert an element at a given index in Python?

1 Answer

0 votes
by

Python has an inbuilt function called the insert() function.

It can be used used to insert an element at a given index.

Syntax: list_name.insert(index, element)

ex: list = [ 0,1, 2, 3, 4, 5, 6, 7 ]

#insert 10 at 6th index

list.insert(6, 10)

o/p: [0,1,2,3,4,5,10,6,7]

Related questions

+1 vote
asked Feb 13, 2021 in Python by SakshiSharma
0 votes
asked Jul 7, 2022 in ElasticSearch by sharadyadav1986
...