How do I print the key-value pairs of a dictionary in python

I want to output my key value pairs from a python dictionary as such:

key1 \t value1
key2 \t value2

I thought I could maybe do it like this:

for i in d:
    print d.keys(i), d.values(i)

but obviously that’s not how it goes as the keys() and values() don’t take an argument.

11 Answers
11

Leave a Comment