While you have been given answers on how you can do it, nobody yet did tell you what you did wrong. There are actually several errors in your code.
The first error is the
i = 34. Here are actually two errors. The first error is that you used an assignment where you actually wanted to do a comparison. Equality comparison is done with
However, even if you replace
i = 34 with
i == 34, the code will still not work. That's because the second argument is not the condition for ending the loop, but the condition for continuing the loop. So the for loop will assign
i, then check
i == 34, find it false, and immediately leave the loop. Therefore you'd have to write
i != 34 or
i < 34 at this point.
If you fix that, you'll notice an error message. That's coming from the assignment
Out = Out[135 + i].
Out is protected and therefore cannot be assigned to. However let's assume it were not protected, what would happen? Well, let's assume
x. Now that value would be assigned to
Out (and then printed). Then in the next iteration, when coming across that assignment again, it would first evaluate
x on the right hand side of the assignment, and then proceed with the statement
Out = x[135+7], assigning x to
Out. Clearly not what you'd want.
To fix that last error, you should use another variable name, say
nextout = Out[135 + i]; Print[CForm[nextout]] or even better, just don't use a variable at this point and just write
Print[CForm[Out[135 + i]]].
After fixing that error as well, the loop works as intended (but the
Do loop suggested by Alexey Popkov is still the better alternative in this case).