Python Tutorial Python Advanced Python References Python Libraries

Python Dictionary - values() Method



The Python values() method is used to display a list containing all values present in the dictionary. If the dictionary is modified, the display object also gets updated.

Syntax

dictionary.values()

Parameters

No parameter is required.

Return Value

Returns dict_values containing all values present in the dictionary.

Example:

In the example below, the values() method is used to display all values present in the given dictionary.

Info = {
  'name': 'John',
  'age': 25,
  'city': 'London'
}
#display a list of all values present in the dictionary.  
x = Info.values()  
print(x)

#Changing on the field values, display object also gets changed. 
Info['city'] = 'Paris'
print(x)

The output of the above code will be:

dict_values(['John', 25, 'London'])
dict_values(['John', 25, 'Paris'])

❮ Python Dictionary Methods