xxxxxxxxxx
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
z = x|y
xxxxxxxxxx
firstSet = {2, 3, 4, 5}
secondSet = {1, 3, 5, 7}
print(firstSet | secondSet)
# {1, 2, 3, 4, 5, 7}
xxxxxxxxxx
set_1 = {1, 2, 3, 4, 5}
set_2 = {3, 4, 5, 6}
# Method 1
union_1 = set_1 | set_2 # {1, 2, 3, 4, 5, 6}
# Method 2
union_2 = set_1.union(set_2) # {1, 2, 3, 4, 5, 6}