'How to format the way dictionaries print in Python?

I am trying to understand how to print this dictionary to look something like this:

color: red
name: volvo

However, the output is returning:

{'color': 'red', 'name': 'volvo'}


Solution 1:[1]

This is the way you are looking to print your dictionaries content

# You can declare a  dictionary like this assigning the keys, to their values
dict_of_cars = {"Color": "Red", "Name": "Volvo"}

# You can iterate through and have the output formatted using a simple for loop
for each_key, each_value in dict_of_cars.items():
    print(f"{each_key}: {each_value}")

For more information on printing dictionaries with Python, visit this link here, and more information on using printf statements here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 yet-it-compiles