Objective

Master Python's core data structures: lists and dictionaries.

Tools & Technologies

  • Python 3
  • list
  • dict
  • collections

Key Commands

lst.append(x)
lst.sort(key=lambda x: x[1])
d.get(key, default)
collections.defaultdict(list)

Lab Steps

01
List Operations

Practice slicing, sorting, filtering, and transforming lists.

02
Dictionary Operations

Use dict methods: get, update, items, keys, values.

03
Nested Structures

Work with lists of dicts and dicts of lists.

04
collections Module

Use defaultdict, Counter, and OrderedDict for specialized needs.

Challenges Encountered

  • Dict key ordering (guaranteed in Python 3.7+)
  • Shallow vs deep copy confusion with nested structures

Key Takeaways

  • Use dict.get() with default to avoid KeyError
  • Counter is the fastest way to count occurrences