Categories

Dec 19, 2019 in Python

Q: How Do You Traverse Through A Dictionary Object In Python?

1 Answer

Dec 19, 2019
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

++++++++++++++++++++++++
Click here to read more about Python
Click here to read more about Insurance

Related questions

Madanswer
Dec 22, 2019 in Python
Dec 19, 2019 in Python
Aug 29 in Python
...