Python Dictionary values() Method

Example

Return Value:

car = {
  "brand": "Porsche",
  "model": "911",
  "year": 1963
}
x = car.values()
print(x)

Running an Instance

Definition and Usage

The values() method returns a view object. This view object contains a list of dictionary values.

The view object will reflect any changes made to the dictionary. Please see the following example.

Syntax

dictionary.values()

Parameter Value

No Parameters

More Examples

Example

When the value in the dictionary changes, the view object will also be updated:

car = {
  "brand": "Porsche",
  "model": "911",
  "year": 1963
}
x = car.values()
car["year"] = 2018
print(x)

Running an Instance