How can I properly output the key and value of a dictionary?


#1

Question

How can I properly output the key and value of a dictionary?

Answer

An easy way to print the key and value stored in that key is to use print as normal, but then put a comma , between the two things you want printed. The comma tells Python you want these things to be displayed on the same line and, by default, they will be separated by a space.
Like this: print thing_1, thing_2.
The resulting output would be whatever is stored in those two variables printed on the same line with a space between them.


FAQ: Learn Python- Loops - Looping over a dictionary