Method Name:
items
Method Signature:
items()
Method Overview:
- The items() method returns the key-value pairs of the dictionary as a dict_items instance.
- As the original dictionary changes e.g., when name-value pairs are added or removed, the changes are reflected in the view.
Parameters:
None
Return Value:
The key-value pairs of the dictionary as a dict_items instance.
Example:
# Example Python program that gets the name-value pairs of a dictionary # Create an instance of dict # Get the name-value pairs of the dict instance print("Dictionary view:"); # Add a point to the dictionary print("Dictionary view after a new point is added:"); |
Output:
Dictionary view: |