How Do You Troubleshoot a “SyntaxError: invalid syntax” Error in Python?

Problem scenario
You do not know why you are getting the error. The line has an "l" (a lowercase "L") or a numeral one ("1") in it.

You may have identified that the line of code is different in one file from another. You cannot tell what is different about your code or why you are getting this error. What should you do?

Enter vi or open Notepad++ to view the code. Search for a lowercase L "l" or a numeral one "1". PEP8 recommends this: "Never use the characters 'l' (lowercase letter el), 'O' (uppercase letter oh), or 'I' (uppercase letter eye) as single character variable names." (This was taken from"

"If a function argument's name clashes with a reserved keyword, it is generally better to append a single trailing underscore rather than use an abbreviation or spelling corruption." (This was taken from

(If you do not have an "l" or a "1" in your code, did you forget to put parentheses around the item being printed? Or is there an unmatched parens "(" or ")" somewhere?)

Leave a comment

Your email address will not be published. Required fields are marked *