Skip to Main Content
Python Workout
book

Python Workout

by Reuven M. Lerner
July 2020
Beginner to intermediate content levelBeginner to intermediate
248 pages
6h 58m
English
Manning Publications
Content preview from Python Workout

4 Dictionaries and sets

Dictionaries (http://mng.bz/5aAz), or dicts, are one of Python’s most powerful and important data structures. You may recognize them from other programming languages, in which they can be known as “hashes,” “associative arrays,” “hash maps,” or “hash tables.”

In a dict, we don’t enter individual elements, as in a list or tuple. Rather, we enter pairs of data, with the first item known as the key and the second item known as the value. Whereas the index in a string, list, or tuple is always an integer, and always starts with 0, dict keys can come from a wide variety of Python types--typically integers or strings.

This seemingly small difference, that we can use arbitrary keys to locate our values, rather than using integer ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python for Data Science

Python for Data Science

Yuli Vasiliev
Robust Python

Robust Python

Patrick Viafore

Publisher Resources

ISBN: 9781617295508Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentErrata PagePurchase Link