Dictionaries have some of the same operators and built-in functions that can be used with strings, lists, and tuples. For example, the in
and not in
operators return True
or 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.
To learn more about dictionaries, you might want to check out Python Basics: Dictionaries.
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. You’ll receive a score upon completion to help you track your learning progress:
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.
Wiggers on July 30, 2019
Very well presented and shows I am not the only one who can’t type and spell!