You have given A and B as2 lists which may have repeated elements in respective list. Write a python function mg-L(A,B) which takes list A and B as input and returns a merged list. The function will merge the list B with A (means the list A will be expanded) such that the resultant A
still contain no duplicates. Specify input in fixed form. Use only list operations. For example if
A =[2,4,8,2,1] and B=[10,4,3,8,7] merged-list =[1,2,3,4,7,8,10]
def merge(A, B):
merged = []
for el in A + B:
if el not in merged:
merged.append(el)
merged.sort()
return merged
A = [2,4,8,2,1]
B = [10,4,3,8,7]
print(merge(A, B))
Comments
Leave a comment