Getting "invalid syntax" in a simple inverse expression is almost impossible. If you use it outside the function, you get a 'return' outside function , if you have the wrong indent, you get an IndentationError , etc.
The only way to get SyntaxError: invalid syntax in the return statement is if it doesn't actually say return at all, but if it contains non-ascii characters like retürn . This will give this error. Now, how can you get this error without seeing it? Again, the only idea I can come up with is that you actually have indentation, but that indentation is not spaces or tabs. For example, you can somehow insert unencrypted space into your code.
Yes it can happen. Yes, it happened to me. Yes, you get SyntaxError: invalid syntax .
Lennart Regebro
source share