Trying to sweep a servo 10 times but my loop isn't working?

Since i is declared global, it is initialized to 0 by default. If i were declared as a local variable with no initializer it could be anything (whatever was in the assigned memory location).