Fix "global name 'i' is not defined" exception caused by typo.

Commit 2d710e0c introduced this simple typo that results in:
  NameError: global name 'i' is not defined