Back to Lesson

Nested Dictionary Compression

Build profound data representations in tight spaces.

Instructions

  • You have raw tuples corresponding to ID and coordinates:
    data = [(1, 0, 0), (2, 5, -2)]
    .
  • Using a dictionary comprehension, assign the ID as the key.
  • Assign a dictionary populated by
    {"x": <val1>, "y": <val2>}
    as the value for the comprehension target!
  • Print the final assembled tree mapping.
main.py
main.py