We can use the “for” and “in” loop for traversing the dictionary object.
>>> site_stats = {'site': 'tecbeamers.com', 'traffic': 10000, "type": "organic"}
>>> for k, v in site_stats.items():
print("The key is: %s" % k)
print("The value is: %s" % v)
print("++++++++++++++++++++++++")
The output is:
The key is: type
The value is: organic
++++++++++++++++++++++++
The key is: site
The value is: tecbeamers.com
++++++++++++++++++++++++
The key is: traffic
The value is: 10000
++++++++++++++++++++++++