Python reference

Python dictionary methods

Look up, loop over and update key-value pairs: get, items, keys, update, pop and more.

A dictionary stores values under keys, like a word and its meaning. Its methods read values safely (get), loop over the contents (keys, values, items), and add or remove entries (update, pop, setdefault).

Most used

All 11 dictionary methods

Spotted a mistake on this page? Tell us