### Thread: Problem when starting a new line in for loop

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
2
Rep Power
0

#### Problem when starting a new line in for loop

Hello,
I'm using Python for an online course (And I'm a begginer to this language). I keep having the same problem. the code I'm trying to run is in the form of:
for step in range(num_steps):
i_ac=acceleration(x[step])
Xe=x[step]+h*v[step]
Ve=v[step]+h*acceleration(x[step])
x[step + 1] = x[step] + h * (v[step]+Ve/2)
v[step + 1] = v[step] + h * 0.5.*(i_ac+acceleration(Xe))

The error in a general "SyntaxError:invalid syntax" in the last line starting with v[step+1]. It occures in the interface of the online course, as well as in komodo editor and begins as soon as I start writing this line. The error message corespond to the column of the letter v in the last line. I made sure that all the line starts on the same position. I incounter this problem repeatidaly and did't manage to pigure it out. I will be grateful for any idea.
2. Originally Posted by itaiv
Hello,
I'm using Python for an online course (And I'm a begginer to this language). I keep having the same problem. the code I'm trying to run is in the form of:
for step in range(num_steps):
i_ac=acceleration(x[step])
Xe=x[step]+h*v[step]
Ve=v[step]+h*acceleration(x[step])
x[step + 1] = x[step] + h * (v[step]+Ve/2)
v[step + 1] = v[step] + h * 0.5.*(i_ac+acceleration(Xe))

The error in a general "SyntaxError:invalid syntax" in the last line starting with v[step+1]. It occures in the interface of the online course, as well as in komodo editor and begins as soon as I start writing this line. The error message corespond to the column of the letter v in the last line. I made sure that all the line starts on the same position. I incounter this problem repeatidaly and did't manage to pigure it out. I will be grateful for any idea.
First of all, use code tags so we don't have to take your word for it about the indentation.

Second: 0.5.
The trailing "." is incorrect.
3. 0.5.*(

See the extra "dot"? It appears in the line you high-lit red.

Please follow the instructions at my signature to post python code. Preserving indentation is possible.
4. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
2
Rep Power
0