Python Dictionary values() Method Tutorial

In this section, we will learn what the Dictionary values() method is and how to use it in Python.

What is Dictionary values() Method in Python?

The Python Dictionary values() method is used to get an object view of the target Dictionary that contains all its values set as the items of a list.

Note that we’re saying a “view” of the values in the target Dictionary! This means if one of the values in the target dictionary changed, this view object will notice the change as well.

Python Dictionary values() Method Syntax:

dictionary.values()

Dictionary values() Method Parameter:

The method does not take an argument.

Dictionary values() Method Return Value

The return value of this method is a view object that contains the entire values of the target Dictionary set as the items in a list.

Example: using python dictionary values() method

dictionary = {

"name":"Jack",

"lastName":"Doe"

}

result = dictionary.values()

print(result)

dictionary["age"] = 200

print(result)

Output:

dict_values(['Jack', 'Doe'])

dict_values(['Jack', 'Doe', 200])
Facebook
Twitter
Pinterest
LinkedIn

Top Technologies