python append at index code example

Example 1: python add to list with index

list.insert(index, element)

Example 2: add element to list python at index

thislist = ["apple", "banana", "cherry"]
thislist.insert(1, "orange")

Example 3: append to lists python

list = []          ## Start as the empty list
  list.append('a')   ## Use append() to add elements
  list.append('b')

Example 4: how to add an item to a list python

numbers = [1, 2, 3, 4]
numbers.append(10)
print(numbers)

Example 5: append to list at index python

#!/usr/bin/python

aList = [123, 'xyz', 'zara', 'abc']
aList.insert( 3, 2009)
print "Final List : ", aList

Example 6: append to list at index python

list.insert(index, obj)