print all values in dictionary python code example
Example 1: how to print all elements of a dictionary in python
my_dict = {"one": 1,"two":2,"three":3,"four":4}
for key,value in my_dict.items():
print("Key : {} , Value : {}".format(key,value))
Example 2: how to print all elements of a dictionary in python
my_dict = {"one": 1,"two":2,"three":3,"four":4}
for item in my_dict:
print("Key : {} , Value : {}".format(item,my_dict[item]))
Example 3: extract values from dict python
>>> d = {1:-0.3246, 2:-0.9185, 3:-3985}
>>> d.values()
<<< [-0.3246, -0.9185, -3985]