The global declaration is when you declare that times is global
def timeit():
global times # <- global declaration
# ...
If a variable is declared global, it can’t be used before the declaration.
In this case, I don’t think you need the declaration at all, because you’re not assigning to times, just modifying it.