Python Dictionary values() Method
Last Updated : 5 Jan 2026
Python values() method is used to return the view object of the values from a dictionary. The view object consists of the values of the dictionary, as a list. The view object reflects any changes done to the dictionary.
Syntax of the values() Method in Python Dictionary
The following is the syntax of the dictionary values() method:
Parameters
- No Parameter
Return
- It returns a view object of the values.
Examples of Dictionary values()
We will now look at some examples of the dictionary values() method.
Example 1: Working of the values() Method
This example shows how the values() method work in Python.
Output:
Electrical Inventory: {'Fan': 200, 'Bulb': 150, 'Led': 1000, 'Socket': 500, 'Tubelight': 600}
Stock available: dict_values([200, 150, 1000, 500, 600])
Explanation:
In this example, we are given a dictionary. We used the values() method to return the view object of the values from the dictionary.
Example 2: Returning Values from an Empty Dictionary
If the dictionary is already empty, this method also returns an empty view object without any error or exception. See an example below:
Output:
Empty Dictionary: {}
Stock available: dict_values([])
Explanation:
In this example, we are given an empty dictionary. We used the values() method to return the view object of the values from the dictionary. Since the dictionary is empty, the returned object is also empty.
Example 3: Reflecting Changes in the View Object
In Python, the view object reflects any changes done in the dictionary. Here is an example:
Output:
Electrical Inventory: {'Fan': 200, 'Bulb': 150, 'Led': 1000, 'Socket': 500, 'Tubelight': 600}
Stock available: dict_values([200, 150, 1000, 500, 600])
Electrical Inventory (Updated): {'Fan': 200, 'Bulb': 150, 'Led': 800, 'Socket': 300, 'Tubelight': 600}
Stock available (Updated): dict_values([200, 150, 800, 300, 600])
Explanation:
In this example, we are given a dictionary. We used the values() method to return the view object of the values from the dictionary. We then updated some items in the dictionary. As a result, the view object also reflects the changes in the dictionary.
Conclusion
The values() method in Python is a powerful dictionary method that allows developers to collect all the values from a dictionary. It does not take any parameters and returns a dictionary of values. It is widely used for data analysis, reporting, and transformations across various industries.