Home >>Python Dictionary Methods >Python Dictionary values() Method

Python Dictionary values() Method

Python Dictionary values() Method

Python Dictionary values() Method is an inbuilt method which is used to returns all the values available in a given dictionary, as a list. It does not take any parameter and if the dictionary has no value it returns an empty value.

Syntax:
dictionary.values()
Here is an example of Python Dictionary values() Method:

per = {
"name": "rohan",
"lname": "singh",
"year": 1990
}
z = per.values()
print(z)

Output:
dict_values(['rohan', 'singh', 1990])
Example 2:

obj = {'lap': 250, 'mobile':350, 'tab':1500}  
obj1 = obj.values()   
print("electronic available",obj)

Output:
electronic available {'lap': 250, 'mobile': 350, 'tab': 1500}

No Sidebar ads