Dictionaries have some of the same operators and built-in functions that can be used with strings, lists, and tuples. For example, the
not in operators return
False according to whether the specified operand occurs as a key in the dictionary.
You can use the
in operator together with short-circuit evaluation to avoid raising an error when trying to access a key that is not in the dictionary. The
len() function returns the number of key-value pairs in a dictionary.
Now that you’ve completed this course, you can test your knowledge with this quiz:
Take the Quiz: Test your knowledge with our interactive “Python Dictionaries” quiz. Upon completion you will receive a score so you can track your learning progress over time:
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.