in Python by
How Do You Traverse Through A Dictionary Object In Python?

▼ Show 1 Answer

0 votes
We can use the “for” and “in” loop for traversing the dictionary object.

>>> site_stats = {'site': '', 'traffic': 10000, "type": "organic"}

>>> for k, v in site_stats.items():

    print("The key is: %s" % k)

    print("The value is: %s" % v)


The output is:

The key is: type

The value is: organic


The key is: site

The value is:


The key is: traffic

The value is: 10000

Learn More with Madanswer

Related questions

+1 vote
asked Feb 13 in Python by SakshiSharma