December 19th, 2012, 04:25 AM
Problem when starting a new line in for loop
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):
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.
December 19th, 2012, 08:42 AM
First of all, use code tags so we don't have to take your word for it about the indentation.
Originally Posted by itaiv
The trailing "." is incorrect.
December 19th, 2012, 08:52 AM
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.
[/code] are essential for python code and Makefiles!
December 19th, 2012, 09:26 AM
Thanks for your replays
I thought I had a problem related to line breaks, sorry for the trouble