CHAPTER 38   •   PYTHON

Python Nested Collections

Learn how to store collections inside other collections.

01 What is this?

Learn how to store collections inside other collections.

02 Syntax

Python Syntax
data = [{'key': 'value'}]

03 Example

Python Example
students = [
    {'name': 'Ali', 'marks': 80},
    {'name': 'Sara', 'marks': 90}
]

print(students[0]['name'])

04 Important Points

Nested structures are common when working with real data.

05 Common Mistakes

Track indexes and keys carefully.

06 Real World Use

APIs and databases often produce nested data structures.

07 Practice This Topic

Now try the example yourself in the AIFA Python Editor.

  • Read the example carefully.
  • Change the values.
  • Run the code.
  • Observe the output.
  • Try creating your own example.
Try It Yourself →