1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Data Pipelines

Exercise

Iterating over dictionaries

Once JSON data is loaded into a dictionary, you can leverage Python's built-in tools to iterate over its keys and values.

The "nested_school_scores.json" file has been read into a dictionary stored in the raw_testing_scores variable, which takes the following form:

{
    "01M539": {
        "street_address": "111 Columbia Street",
        "city": "Manhattan",
        "scores": {
              "math": 657,
              "reading": 601,
              "writing": 601
        }
  }, ...
}

Instructions 1/3

undefined XP
  • 1
    • Loop through the keys of the raw_testing_scores dictionary.
    • Add each key to the raw_testing_scores_keys list.
  • 2
    • Now, loop through a list of values from the raw_testing_scores dictionary.
  • 3
    • Finally, loop through both the keys and values of the raw_testing_scores dictionary, simultaneously.