python - How to empty out elements of two arrays after merging two arrays together -
#function def merge_array(a, b): c = [] in a: c.append(i) z in b: if z not in c: c.append(z) c.sort() return c #main = [1,5,2,8,9] b = [8,4,2,8,10,3,14] print("array 1: {}".format(a)) print("array 2: {}".format(b)) print("merged list: {}".format(merge_array(a, b))) print("array 1 empty: {}".format(a)) print("array 2 empty: {}".format(b))
tried putting a.pop() , b.pop() in loops not erase elements , changes 'c'
not quite sure if looking if want add lists , take care of duplicates try:
list(set(a+b))
Comments
Post a Comment