Google News
logo
Python Program to Print all values in a dictionary, one by one
In the following example of Python program to print all the values in a dictionary, one by one :
Program :
my_dict = {"name": "John", "age": 30, "city": "New York"}

for value in my_dict.values():
    print(value)
Output :
John
30
New York
In this program, we first create a dictionary `my_dict` containing three key-value pairs.

Then, we use a `for` loop to iterate through all the values in the dictionary using the `values()` method.

Inside the loop, we simply print each value one by one using the `print()` function.