Name

.items()

Examples

element_names = {'H': 'hydrogen', 'He': 'helium', 'Li': 'lithium'}
element_items = element_names.items()

# Prints [('Li', 'lithium'), ('H', 'hydrogen'), ('He', 'helium')]
print(element_items)

# Iterate over each item of the dictionary:
for k, val in element_names.items():
	print("The name of element " + k + " is " + val)

Description Returns the key/value pairs present in the dictionary, in the form of a list of tuples. For large dictionaries, consider using iteritems() instead, which returns an iterator.

Note that because of the nature of the dictionary data structure, key/value pairs returned from items() will be in arbitrary order (not necessarily the order they appeared in when the dictionary was defined).
Syntax
	dict.items()
Parameters
dictThe dictionary whose items will be returned.
Related Dictionary

Updated on Tue Feb 27 14:07:12 2024.

If you see any errors or have comments, please let us know.