<jupyter_start><jupyter_text>All the IPython Notebooks in this **Python Examples** series by Dr. <NAME> are available @ **[GitHub](https://github.com/milaan9/90_Python_Examples)**  Python Program to Iterate Over Dictionaries Using for LoopIn this example, you will learn to iterate over dictionaries using **`for`** loop.To understand this example, you should have the knowledge of the following **[Python programming](https://github.com/milaan9/01_Python_Introduction/blob/main/000_Intro_to_Python.ipynb)** topics:* **[Python for Loop](https://github.com/milaan9/03_Python_Flow_Control/blob/main/005_Python_for_Loop.ipynb)*** **[Python Dictionary](https://github.com/milaan9/02_Python_Datatypes/blob/main/005_Python_Dictionary.ipynb)**<jupyter_code># Example 1: Access both key and value using items()

dt = {'a': 'time', 'b': 'money', 'c': 'health'}

for key, value in dt.items():
    print(key, value)
        
'''
>>Output/Runtime Test Cases:
     
a time
b money
c health
'''<jupyter_output>a time
b money
c health<jupyter_text>**Explanation:*** Using a **`for`** loop, pass two loop variables **`key`** and **`value`** for iterable **`dt.items()`**. **`items()`** returns the **`key:value`** pairs.* Print **`key`** and **`value`**.<jupyter_code># Example 2: Access both key and value without using items()

dt = {'a': 'time', 'b': 'money', 'c': 'health'}

for key in dt:
    print(key, dt[key])
        
'''
>>Output/Runtime Test Cases:
     
a time
b money
c health
'''<jupyter_output>a time
b money
c health<jupyter_text>**Explanation:*** Iterate through the dictionary using a **`for`** loop.* Print the loop variable **`key`** and **`value`** at key (i.e. **`dt[key]`**).However, the more pythonic way is example 1.<jupyter_code># Example 3: Return keys or values explicitly

dt = {'a': 'time', 'b': 'money', 'c': 'health'}

for key in dt.keys():
    print(key)

for value in dt.values():
    print(value)
        
'''
>>Output/Runtime Test Cases:
     
a
b
c
time
money
health
'''<jupyter_output>a
b
c
time
money
health
{'fraction_non_alphanumeric': 0.1674052191038897, 'fraction_numerical': 0.012309207287050714, 'mean_word_length': 4.906976744186046, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '513071', 'license': 'MIT', 'n_tokens_mistral': 734, 'n_tokens_neox': 685, 'n_words': 219, 'path': '03_Python_Flow_Control_examples/014_iterate_over_dictionaries_using_for_loop.ipynb', 'repo_name': 'peterennis/90_Python_Examples', 'size': '2038'}