Professional Documents
Culture Documents
To remove elements from sets, Use discard method on sets as shown below
Discard method has advantage, if the element that you are trying to discard in the
set is not present in there is nor error raised in python.
But if you try to remove any element, using remove method on the set. Python
raises an error if element is not present in the set.
How to check whether a set is subset of another
DICTIONARIES
A dictionary is a container that keeps associations between keys and values. Every key
in the dictionary has an associated value. Keys are unique, but a value may be
associated with several keys. Figure 7 gives a typical example: a dictionary that
associates names with colors might describe the favorite colors of various people. The
dictionary structure is also known as a map because it maps a unique key to a value. It
stores the keys, values, and the associations between them.
To remove an element from dictionary use the pop method in the following way
To access whole dictionary, use the loop in the following way