Hey 👋 I'm a software engineer, an author, and an open-source contributor. I enjoy helping people (including myself) decode the complex side of technology. I share my findings on Twitter: @lavary_
Python raises “SyntaxError: unterminated triple-quoted string literal” when you use a pair of triple quotes (“”” or ”’) around a multi-line string literal, but the ending part is missing. Here’s what the error looks like on Python version 3.11: On the other hand, the error …
🚫 SyntaxError: ‘return’ outside function Python raises the error “SyntaxError: ‘return’ outside function” once it encounters a return statement outside a function. Here’s what the error looks like: Based on Python’s syntax & semantics a return statement may only be used in a function – to return a value …
🚫 SyntaxError: positional argument follows keyword argument Python raises the “SyntaxError: positional argument follows keyword argument” error if you place one or more keyword arguments (e.g., age=35, name=John) before your positional arguments (e.g., 35, John) in a function call. Based on Python syntax, keyword arguments must follow positional arguments …
🚫 SyntaxError: Missing parentheses in call to ‘print’ The error “SyntaxError: Missing parentheses in call to ‘print’. Did you mean print(…)?” in Python happens when you use an old-style print statement (e.g., print ‘some value’) in Python 3. This long error looks like this: As …
🚫 SyntaxError: invalid non-printable character The error “SyntaxError: invalid non-printable character” in Python happens once Python encounters an invalid non-printing character (according to Python’s syntax) in your statements. Non-printing characters might not be visible in your code editor, and you might not notice them until you run the …
🚫 SyntaxError: invalid character in Python The error “SyntaxError: invalid character” in Python happens once Python encounters an invalid character (according to Python’s syntax) in your statements. You may have invalid characters in your code if: You’ve copied a code snippet from a web page, …
🚫 SyntaxError: unterminated string literal Python raises “SyntaxError: unterminated string literal” when a string value doesn’t have a closing quotation mark. This syntax error usually occurs owing to a missing quotation mark or an invalid multi-line string. Here’s what the error looks like on Python …
Python raises “SyntaxError: EOL while scanning string literal” when it reaches the end of the line, yet it hasn’t encountered the closing quotation mark (‘ or “) of a string literal. This syntax error usually occurs owing to a missing quotation mark or an invalid …
🚫 SyntaxError: cannot assign to expression here Python raises “SyntaxError: cannot assign to expression here. Maybe you meant ‘==’ instead of ‘=’?” when you assign a value to an expression. On the other hand, this error occurs if an expression is the left-hand side operand …
🚫 SyntaxError: cannot assign to literal here Python raises “SyntaxError: cannot assign to literal here. Maybe you meant ‘==’ instead of ‘=’?” when you assign a value to a literal (e.g., 12, ‘49.5’, ‘Sally’). On the other hand, this error occurs if a literal value …
🚫 SyntaxError: cannot assign to function call Python raises “SyntaxError: cannot assign to function call here. Maybe you meant ‘==’ instead of ‘=’?” when a function call is the left-hand side operand in a value assignment: Python also provides you a hint, assuming you meant …
🚫 SyntaxError: ‘continue’ not properly in loop Python raises “SyntaxError: ‘continue’ not properly in loop” whenever it encounters a continue statement outside a loop – usually within an if block that’s not part of a loop. Here’s what the error looks like: A continue statement …
🚫 SyntaxError: ‘break’ outside loop Python raises “SyntaxError: ‘break’ outside loop” whenever it encounters a break statement outside a loop. The most common cases are using break within an if block (that’s not part of a loop) or when you accidentally use it instead of …
🚫 SyntaxError: invalid decimal literal The Python error “SyntaxError: invalid decimal literal” occurs if you use an invalid decimal literal in a Python expression, like 453a, or amount = 12.5a, or 100_step = ‘someValue’. Here’s what the error looks like: A SyntaxError is a type …
⛔ TypeError: ‘bool’ object is not callable The “TypeError: ‘bool’ object is not callable” error occurs when you try to call a boolean value (bool object) as if it was a function! Here’s what the error looks like: In the simplest terms, this is what …