Google News
logo
Python Program to Using the values() function to return values of a dictionary
In the following example of Python program to demonstrate how to use the `values()` function to return values of a dictionary :
Program :
# create a dictionary
my_dict = {"apple": 2, "banana": 3, "orange": 4}

# print the values of the dictionary using values() function
for value in my_dict.values():
    print(value)
Output :
2
3
4
In the above program, we have created a dictionary named `my_dict`. Then, we have printed all the values of the dictionary using a `for` loop and the `values()` function of the dictionary object.