python – Syntax Error: invalid syntax for no apparent reason
python – Syntax Error: invalid syntax for no apparent reason
For problems where it seems to be an error on a line you think is correct, you can often remove/comment the line where the error appears to be and, if the error moves to the next line, there are two possibilities.
Either both lines have a problem or the previous line has a problem which is being carried forward. The most likely case is the second option (even more so if you remove another line and it moves again).
For example, the following Python program twisty_passages.py
:
xyzzy = (1 +
plugh = 7
generates the error:
File twisty_passages.py, line 2
plugh = 7
^
SyntaxError: invalid syntax
despite the problem clearly being on line 1.
In your particular case, that is the problem. The parentheses in the line before your error line is unmatched, as per the following snippet:
# open parentheses: 1 2 3
# v v v
fi2=0.460*scipy.sqrt(1-(Tr-0.566)**2/(0.434**2)+0.494
# ^ ^
# close parentheses: 1 2
Depending on what youre trying to achieve, the solution may be as simple as just adding another closing parenthesis at the end, to close off the sqrt
function.
I cant say for certain since I dont recognise the expression off the top of my head. Hardly surprising if (assuming PSAT is the enzyme, and the use of the typeMolecule
identifier) its to do with molecular biology – I seem to recall failing Biology consistently in my youth 🙂
Youre missing a close paren in this line:
fi2=0.460*scipy.sqrt(1-(Tr-0.566)**2/(0.434**2)+0.494
There are three (
and only two )
.
python – Syntax Error: invalid syntax for no apparent reason
If you are running the program with python, try running it with python3.