Psst! Check what courses we have in our offer, and get them all here to save $727. Tick-tock—this deal ends on 3/21.
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')