list_of_names = ["John", "Mike"]
print(list_of_names)
list_of_names.insert(0,"Amy") #insert Amy as the first item, at index 0
print(list_of_names)
list_of_names.insert(2,"Mario") #insert Mario as the third item, at index 2
print(list_of_names)
#['John', 'Mike']
#['Amy', 'John', 'Mike']
#['Amy', 'John', 'Mario', 'Mike']
list_of_names = [] #create an empty list
print(list_of_names)
list_of_names.append("Greg")
print(list_of_names)
list_of_names.append("Mario")
print(list_of_names)
list_of_names.append("Maria")
print(list_of_names)
#[]
#['Greg']
#['Greg', 'Mario']
#['Greg', 'Mario', 'Maria']
Use of Append:
list = [1,2,3,4,5]
list.append(6)
print(list) # [1,2,3,4,5,6]
Use of Insert:
list = [1,2,3,4,5]
list.insert(5, 10) # [1,2,3,4,5,10]
list.insert(1, 10) # [1,10,3,4,5]