Back to Lesson

Complex Keys

Understand what bounds determine dictionary keys.

Instructions

  • Create an empty dictionary
    grid = {}
    .
  • Add a key for the tuple
    (0, 0)
    mapping to
    "Start"
    .
  • Use a
    try...except TypeError
    block where you attempt to assign
    grid[[1, 1]] = "Trap"
    . In the
    except
    block, print
    "Invalid key"
    .
main.py
main.py