Dict Methods
dict.items()
Returns a live view whose elements are (key, value) tuples in dictionary insertion order. A later modification is visible when the view is traversed again. Converting the view to a list captures current pairs but still shares mutable values. Item membership can compare a pair even if its value is unhashable; set operations that must hash such a pair can fail. Avoid changing the dictionary size while iterating a view. Reverse traversal is supported from Python 3.8, and the mapping attribute offers a live read-only proxy from 3.10.
Formal Syntax & Structure
python syntaxpython
mapping.items()Return Value
dict_items
Reusable dynamic item view, not an iterator or independent list.
Working Example
Example Snippetpython
scores = {"Ada": 8, "Sam": 7}pairs = scores.items()scores["Ada"] = 9scores["Lee"] = 6print(list(pairs))print(("Sam", 7) in pairs)