O'Reilly logo

Learn More Python 3 the Hard Way: The Next Step for New Python Programmers by Zed A. Shaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required