Items method
The Python dictionary items() method returns a dynamic view of the dictionary’s key-value pairs.
The Quick Python Book, Fourth Edition
The dictionary items method returns the dictionary's key-value pairs as iterable tuple-like items.
- How it is used
- Uses dictionary items to iterate over key-value pairs and prepare word counts for sorting.
- How deep it goes
- Explains the dynamic view, list conversion, membership tests, conditional set operations, and sorting by tuple value.
- Examples
- Demonstrates English-to-French dictionary entries and a word-frequency exercise that selects the most and least common words.
- What you can do after
- Apply it via Python dictionaries to iterate over entries and sort word-frequency pairs.
Read how The Quick Python Book, Fourth Edition explains items method →
Python Workout: 50 ten-minute exercises
dict.items is the dictionary method that returns an iterator over the dictionary's key-value pairs.
- How it is used
- Uses dictionary iteration to process key-value pairs for formatting, transformation, and generated attributes.
- How deep it goes
- Explains the returned iterator, pair unpacking, and comprehensions, stopping short of implementation internals.
- Examples
- Demonstrates XML-like attribute generation and dictionary value transformation.
- What you can do after
- Apply it via comprehensions to build formatted strings or new dictionaries from existing key-value pairs.
Read how Python Workout: 50 ten-minute exercises explains items method →
Also covered in
- Python Workout, Second Edition
- Python How-To
- Tiny Python Projects: Learn coding and testing with puzzles and games
What to know first
- MapA map is an associative data structure that stores key-value associations and supports retrieving values by key.
- loopA loop is a programming-language control-flow construct that repeatedly executes a block of instructions according to an iteration rule or continuation condition.
- comprehensionA comprehension is a language construct that creates a collection by iterating over one or more sources, optionally filtering elements and transforming them.
- floating-point arithmeticFloating-point arithmetic is numerical computation using finite-precision representations of real numbers, which can introduce rounding and range errors.
Related concepts
- iteratorproduces · An iterator is an object or abstraction that provides successive values from a collection or other data source through a traversal interface.
- key-value pairproduces · A key-value pair is a data association in which a key identifies or provides access to its corresponding value.
- tupleproduces · A tuple is a finite, ordered collection of values grouped as a single composite value, often with elements of different types.
- comprehensionuses · A comprehension is a language construct that creates a collection by iterating over one or more sources, optionally filtering elements and transforming them.
- dictionary view objectproduces · A dictionary view object is a dynamic Python object exposing a dictionary’s keys, values, or key-value pairs and reflecting subsequent dictionary changes.
- Mapuses · A map is an associative data structure that stores key-value associations and supports retrieving values by key.
Questions about items method
What is items method?
The Python dictionary items() method returns a dynamic view of the dictionary’s key-value pairs.
Which Manning books explain items method?
The Quick Python Book, Fourth Edition and Python Workout: 50 ten-minute exercises.
What should I know before learning items method?
Manning books that teach items method usually introduce Map, loop, comprehension and floating-point arithmetic first.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

