python append in specific position

Solutions on MaxInterview for python append in specific position by the best coders in the world

showing results for - "python append in specific position"
Brittany
03 Jan 2019
1# --> list.insert(position, element) <--
2
3# List of string 
4list1 = ['Hi' ,  'hello', 'at', 'this', 'there', 'from']
5
6# Add an element at 3rd position in the list
7list1.insert(3, 'why')
8#-> ['Hi', 'hello', 'at', 'why', 'this', 'there', 'from']