python how to add a string to a list in the middle

Solutions on MaxInterview for python how to add a string to a list in the middle by the best coders in the world

showing results for - "python how to add a string to a list in the middle"
Mariangel
14 Apr 2019
1listexample['exampleone', 'examplethree']
2listexample.insert(1, 'exampletwo')
3print(listexample)
4#prints ['exampleone', 'exampletwo', 'examplethree']
5#Use the insert() method when you want to add data to the beginning or middle of a list. 
6#Take note that the index to add the new element is the first parameter of the method.