1# Makes list1 longer by appending the elements of list2 at the end.
2list1.extend(list2)
3
1>>> l1 = [1, 2, 3]
2>>> l2 = [4, 5, 6]
3>>> joined_list = [*l1, *l2] # unpack both iterables in a list literal
4>>> print(joined_list)
5[1, 2, 3, 4, 5, 6]
6
1from heapq import merge
2
3# initializing lists
4test_list1 = [1, 5, 6, 9, 11]
5test_list2 = [3, 4, 7, 8, 10]
6
7# printing original lists
8print ("The original list 1 is : " + str(test_list1))
9print ("The original list 2 is : " + str(test_list2))
10
11# using heapq.merge()
12# to combine two sorted lists
13res = list(merge(test_list1, test_list2))
14
15# printing result
16print ("The combined sorted list is : " + str(res))