You know I am a long-time matlab and fortran user. Those languages use explicit end or continue statements to terminate a loop. In Python you must use indentation to identify statements that are in the loop. The example below will not run if I do not put a statement (any statement) at the first indentation level to terminate the inner loop. i.e. if you try to drop down 2 levels of indentation there is an invalid syntax error. So if you comment out the first print statement the error occurs. Is that just the way it is? Is there some kind of dummy continue or enddo statement in Python that can serve as a placeholder for this? I get this error when using python2.7 on Linux. Note using the Spyder Python 3 environment on PC it runs fine with or without the print statement!
from numpy import *
nt=11
nres=2
t=zeros(nt)
y=zeros((nres,nt))
for it in range(nt):
if it == 0:
t[it]=0.
else:
t[it]=t[it-1]+1./(nt-1)
for ir in range(nres):
y[ir,it]=sin(pi*t[it]+ir*pi/2)
# need a statement at this level to terminate inner for loop
print('it=',it,'t=',t[it],'y(:,it)=',y[:,it])
print('end of outer loop')