Exercise 17. Dictionary
You should be familiar with Python’s dict
class already. Any time you write code like
cars = {'Toyota': 4, 'BMW': 20, 'Audi': 10}
you’re using a dict
to associate the models of cars ('Toyota', 'BMW', 'Audi'
) to the total you have (4, 20, 10
). Using this data structure should be second nature to you by now, and you probably don’t even think about how it works. In this exercise you will learn how a dict
works by implementing your very own Dictionary
from data structures you already created. Your goal in this exercise is to implement your own version of a Dictionary
based on code I’ve written here.
Exercise Challenge
In this exercise you are going to fully document and understand a piece of code ...
Get Learn More Python 3 the Hard Way: The Next Step for New Python Programmers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.