Get all values in a Python dictionary

All values from a dictionary

The values method returns a list of values in the dictionary. Unlike the keys method the values method can have duplicates.

values method has the following syntax.

adict.values()

All stored values in adict. In Python 2.X, this returns a list. In Python 3.0, it returns an iterable view object.


# from   ww w.  j  a  v a  2 s  .  c  om
d = {} 
d[1] = 1 
d[2] = 2 
d[3] = 3 
d[4] = 1 
d.values() 




















Home »
  Python »
    Data Types »




Data Types
String
String Format
Tuple
List
Set
Dictionary