#!/usr/bin/env python def Merge(x,y): """ Returns a float list that is the merge of sorted lists x and y. PreC: x and y are lists of floats that are sorted from small to big. """ # Make copies of x and y so as not to modify these lists in the caller u = list(x) v = list(y) # z will be built up through repeated appending z = [] while len(u)>0 and len(v)>0 : if u[0]<= v[0]: g = u.pop(0) else: g = v.pop(0) z.append(g) print z # On eof the lists u and v have been exhauisted. # Add whatever is left onto the end of z z.extend(u) z.extend(v) print z return z if __name__ == '__main__': x = [10,20,30,40,50] y = [1,11,12,31] print x print y z = Merge(x,y)