I want to define a recursive function to merge two sorted lists (these two lists are sorted) and return a new list containing all the values in both argument lists with a incre
Instead of return, you should add it to the alist as like below.
def combine(a, b):
alist = []
if a == [] and b == []:
return alist
if a != [] and b == []:
return alist + a
if a == [] and b != []:
return alist + b
if a != [] and b != []:
if a[0] <= b[0]:
alist.append(a[0])
alist = alist + combine(a[1:], b)
if a[0] > b[0]:
alist.append(b[0])
alist = alist + combine(a, b[1:])
return alist