How to get the difference between two sets in Python


Python tip:

You can use .difference() to get a new set that contains unique elements that are in the first set but not in the second one.

For example:

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

print(players.difference(winners))
# => {'Bob', 'Daisy'}