Write a purely recursive Python function called
Merge3that takes three lists of numbers each sorted in increasing order as input and outputs a single sorted list by merging elements from the three lists in proper increasing order. For example,
Merge3([1,2,72,108],[3,4,94,103],[45,67,456])should return a list
I was able to write a version for two lists, but I'm struggling to come up with a compact way to do this for three lists. See my example below:
def Merge2(A, B): if A == : return B if B == : return A if A !=  and B != : if A > B: return [B] + Merge(A, B[1:]) else: return [A] + Merge(A[1:], B) print(Merge2([1, 2, 6, 7],[3, 4, 8, 9]))
Is there an easy way to do this for three lists that I'm missing? I feel like it's going to require a lot of additional checking that will make the program fairly long. Can you come up with a concise way to do this for three lists?