# subroutine to merge two sorted lists def merge (list1,list2): print (list1, list2) if len(list1) == 0 and len(list2) == 0: return [] if len(list1) == 0: print("list 2",list2) return list2 if len(list2) == 0: print("list 1",list1) return list1 if list1[0] <= list2[0]: return [list1[0]] + merge(list1[1:], list2) if list2[0] <= list1[0]: return [list2[0]] + merge(list1, list2[1:]) list1 = [3, 7, 9] list2 = [1, 2, 5, 10] mergedList = merge(list1,list2) print(list1, list2, mergedList)