Error in code

that's why it has different values.

A for loop has ONE index. How you USE that value in the body is up to you. RTFM on the for statement.