I don’t get that message running that code. I get that message if I provide a symbol as the Do iterator and the symbol doesn’t evaluate to a number. Is this the exact code, or did you try to simplify the example? I would need to more about what happened in your session. Have you tried quitting the kernel and trying again?
FWIW, you shouldn’t expect that code to actually resolve to any value. Well, more accurately it should evaluate to Null.
I started with a clean fresh notebook and tried with and without initializing the index variable. What is attached is the complete notebook, test05.nb.
Ah. The problem is that you’re using an invalid variable name. The underscore character in Mathematica is used as a shortcut for Pattern. When you did this:
index_a = 0
you actually created a replacement rule for expressions that have a as their head. That doesn’t really have anything to do with the iteration variable in Do, because Do will localize that automatically. Still, Do expects a symbol as the iteration variable, not a Pattern expression.
To fix both of these issues, choose a variable name that doesn’t include reserved characters.
Having said that, I notice that these error messages are different than what you reported before, so we still haven’t figured out what was going wrong before.