Union multiple sets in Python


Python tip:

You can use .union() to create a new set containing unique elements that are either in the first set, the second set, or in both of them.

👇

winners = {"John", "Marry"}
players = {"Daisy", "John", "Bob", "Marry"}

print(winners.union(players))
# => {'John', 'Marry', 'Bob', 'Daisy'}