While using the insert function is it mandatory to the word index itself? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

While using the insert function is it mandatory to the word index itself?

3rd Oct 2016, 9:14 AM
Daniel Sam
Daniel Sam - avatar
2 Answers
+ 1
I think I know what you're thinking of, in the example SoloLearn gave they used the word "index". Well if you look at the example again you can see that they said index=1 So rather than using index, use a number. The number is supposed to represent where you want to insert it.
5th Oct 2016, 12:08 AM
Darth Vador
Darth Vador - avatar
+ 1
Exactly as darth said, index represents the place at which you would like the number to be inserted. For example,if we have , list=[1,2,4,6] list.insert (2,8) print(list) The output will be [1,2,8,4,6] where 8 is inserted at 2nd index.
8th Oct 2016, 4:33 AM
Ashu