Python Dictionary values() Method
In this tutorial, we are going to learn the methods to find the values of a dictionary in Python. In Python, we have keys and values by a semicolon ( : ) enclosed within curly braces { }.
How to find Dictionary values( ) in Python
In Python dictionary, values( )
returns the list of all the values available in a dictionary.
Let us generate a random dictionary in Python.
dict={'a':1,'b':2,'c':3,'d':4}
As we can see in the above code, we have a dictionary followed by keys and values. Now we will check how to return all the values( ) available.
- name.values():- name is the name of the variable stored in a dictionary. It will return all the values from a dictionary.
print(dict.values())
As we can see in the above dictionary, we have values ( 1,2,3,4). So it will return all the values.
dict_values([1, 2, 3, 4])
Leave a Reply