You have given A and B as two lists with may have repeated element in the respective list. Write a python function Merge_List(A, B) which take list A and B as input and return 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.
Example-1
Example-2
Example-3
Input:
A:
1
2
3
4
5
B:
1
1
1
11
2
3
Output:
[1, 2, 3, 4, 5, 11]
Input:
A:
1
2
3
4
5
B:
1
2
3
4
5
Output:
[1, 2, 3, 4, 5]
Input:
A:
1
2
3
B:
4
5
Output:
[1, 2, 3, 4, 5]
def merge(A,B):
temp = set(A)
for item in B:
temp.add(item)
return temp
A = [1,2,3,4,5]
B = [1,2,3,4,5]
print(merge(A,B))
Comments
Leave a comment