how to find union of two lists in python code example
Example: list union python
set1 = {2, 4, 5, 6}
set2 = {4, 6, 7, 8}
set3 = {7, 8, 9, 10}
# union of two sets
print("set1 U set2 : ", set1.union(set2))
# union of three sets
print("set1 U set2 U set3 :", set1.union(set2, set3))
>>>
set1 U set2 : {2, 4, 5, 6, 7, 8}
set1 U set2 U set3 : {2, 4, 5, 6, 7, 8, 9, 10}