I think you are better to check the indentation level, which is an essential to define a code block for Python.
Here is a good summary by Raymond.
In your case, I guess, even “m” is defined before, if an indentation of “for i in range(m):” is not correct, then, this is a possible error. Here is an example of a bad case.
And, here is a good case.
Please double check.