Why does this happen? Normally, when we create variables (like count
= ... in counter), we create the variable in the local frame. Thus
count is marked as a local variable in the counter function.
However, notice that we tried to compute count + 1 before the local
variable was created! That's why we get the UnboundLocalError.

To avoid this problem, we introduce the nonlocal keyword. It allows
us to update a variable in a parent frame. Consider this improved
example:

Question 3

Recall make_test_dice from the Hog project. make_test_dice takes
in a sequence of numbers and returns a zero-argument function. This
zero-argument function will cycle through the list, returning one
element from the list every time. Implement make_test_dice.

Question 8

We'd like to be able to cash checks, so let's add a deposit_check
method to our CheckingAccount class. It will take a Check object
as an argument, and check to see if the payable_to attribute matches
the CheckingAccount's holder. If so, it marks the Check as
deposited, and adds the amount specified to the CheckingAccount's
total. Here's an example: