add 2 elements to list python code example

Example 1: python add to list

list_to_add.append(item_to_add)

Example 2: python push to list

append(): append the object to the end of the list.
insert(): inserts the object before the given index.
extend(): extends the list by appending elements from the iterable.

Example 3: append two list of number to one python

listone = [1,2,3]
listtwo = [4,5,6]
mergedlist = []
mergedlist.extend(listone)
mergedlist.extend(listtwo)

Example 4: python add elements of two lists together

list1 = [1, 2, 3]
list2 = [4, 5, 6]
sum_list = []

for (item1, item2) in zip(list1, list2):
	sum_list.append(item1 + item2)

print(sum_list)