9
Question Question 9
Which of the following will raise an error if the given key is not found in the dictionary ?
- del statement
- pop( )
- popitem()
- all of these
del statement
Reason — For example:
d = {'list': 'mutable', 'tuple': 'immutable'}
del d['dictionary']Output
<module> KeyError: 'dictionary'
Since key named "dictionary" does not exist in d, del keyword will raise an error.