StudyToCert

All certifications / PCEP / Lessons

PCEP – Certified Entry-Level Python Programmer PCEP-30-02 · Domain 3: Data collections: tuples, dictionaries, lists and strings

Dictionaries: building, indexing, adding, changing and removing keys

▶ Watch the overview video

Last reviewed September 30, 2026 · Leer en español

A dictionary (type dict) stores key-value pairs. Instead of looking items up by numeric position, as with a list, you look them up by a meaningful key, the way you look up a word in a real dictionary to find its definition. You write a dictionary in curly braces with a colon between each key and its value and commas between pairs: ages = {"Ana": 31, "Ben": 27}. An empty dictionary is {} or dict(). Note that {} is an empty dict, not an empty set. You can also build one from pairs, as in dict([("a", 1), ("b", 2)]), or with keyword arguments, as in dict(a=1, b=2).

Free account

Keep reading for free

Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 7 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.

Sign up free Log in

Study PCEP for free
A week-by-week plan with every lesson, quizzes, checkpoint tests, a practice exam and hands-on labs.
Open the PCEP study plan