invalid syntax
GustavW (1)

Hi everyone.
I get "invalid syntax" on this:
for i in range(1, n)
print (t[i], F[i])
..where t, F and n of course are defined. Why the error message?

You are viewing a single comment. View All
Answered by JustARatherRidi (203) [earned 5 cycles]
View Answer

Did you define them correctly?

GustavW (1)

@MATTHEWBECHTEL I'm beginning to think I haven't. Here are the relevant parts of the program. It's a numerical solution to Lotka-volterra equations, using Euler.

dt=(tf-t0)/(n-1) #tidssteg
t=np.linspace(t0, tf, n) #tidsarray

R=np.zeros([n]) #Skapa array för kaniner och rävar


for i in range(1,n):

for i in range(n):
print (t[i], F[i])


I don’t know what Lotka-volterra equations or [email protected] is. And yeah, you should probably define those variables.

GustavW (1)

@MATTHEWBECHTEL It's just some first order differential equations, and Euler is a numerical method of solving them. F and t are defined arrays. The error implies that the program doesn't understand the print command. If something was undefined, wouldn't that generate another error, like "undefined blabla" ?