append 2 elements to list python code example
Example 1: append two items to list
my_list = ['a']
my_list.append('b')
my_list.extend(('b','c'))
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 append multiple values
list.extend(val1,val2,val3....)
list.extend( [val1,val2],val3,val4,[val5,val6,val7])