I got a weird situation where Pylint is flagging a "syntax-error" in the last line of the following code snippet, even though the code seems to be working as expected for my tests.
if n>2:
for i in range(0,n):
print(check_prime(i), end = " ")
Can someone help me understand why Pylint is raising this error? Is there an issue with my code or is it possibly a false positive from Pylint? Any reasons as to why this happens?
Your code is clearly a Python 3 code (one can see that because you use the print function).
But, if you run PyLint installed on a Python 2 virtualenv, you get an error:
************* Module ...
E: 11, 0: invalid syntax (<string>, line 11) (syntax-error)
To solve that, you need a Python 3 virtualenv.
python -m venv my_projet
source my_project/bin/activate
pip install pylint
pylint path/to/my_file.py