xxxxxxxxxx
s1 = {'Python', 'Java'}
s2 = {'C#', 'Java'}
s = s1.union(s2)
print(s)
xxxxxxxxxx
# Creating two sets
set1 = {1, 2, 3, 4}
set2 = {3, 4, 5, 6}
# Using the union() method to combine the sets
union_set = set1.union(set2)
# Printing the resulting set
print(union_set)
xxxxxxxxxx
firstSet = {2, 3, 4, 5}
secondSet = {1, 3, 5, 7}
print(firstSet | secondSet)
# {1, 2, 3, 4, 5, 7}
xxxxxxxxxx
#Combine two sets on python: 2nd way.(Union)
set_A= {"Apple", "Orange", "coconut"}
set_B= {"Green","Blue", "Yellow"}
set_C= set_A.union(set_B)
for x in set_C:
print(x )