Spring Deals - hours only!Up to 70% off on all courses and bundles.-Close
Set basics
6. Deleting elements – discard()
Relationships between sets


Perfect! Removing elements from sets is also very easy. There are several ways to do it. Let's start with the discard() method:

favorite_movies = {'Halloween', 'A Star Is Born', 'Hocus Pocus'}
favorite_movies.discard('Hocus Pocus')

The discard() method deletes a given element from a set. If the element we're trying to delete is not present in the set, Python simply ignores the method invocation and does nothing.


Unfortunately, Nancy Silva quit. Delete her from the set, and print the set.

Stuck? Here's a hint!


new_branch_employees.discard('Nancy Silva')