values(): a view object that displays all the values in a dictionary
values(), takes no argument .
Returns : View object containing values .
The original dictionary is not changed after this method.
view object of values
my_dict={'a':'One','b':'Two','c':'Three'}
x=my_dict.values()
print(x)
Output is here
dict_values(['One', 'Two', 'Three'])
View object reflects the changes in dictionary.
my_dict={'a':'One','b':'Two','c':'Three'}
x=my_dict.values()
print(x)
my_dict.update({'c':'New Value'})
print(x)
Output (2nd print(x) reflects the changes )
dict_values(['One', 'Two', 'Three'])
dict_values(['One', 'Two', 'New Value'])
« All dictionary methods
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com