Global changed to local

A variable declared in a for loop was declared as global.