Friendly SyntaxError tracebacks - in English

Friendly-traceback aims to provide friendlier feedback when an exception is raised than what is done by Python. This file contains only examples of SyntaxError and its sub-classes. Ideally, an example of each case handled by friendly-traceback should be included here.

Note

The content of this page is generated by running trb_syntax_english.py located in the tests/ directory. This needs to be done explicitly, independently of updating the documentation using Sphinx. On Windows, if Sphinx is installed on your computer, it is suggested instead to run make_trb.bat in the root directory as it will create similar files for all languages and update the documentation.

Friendly-traceback version: 0.0.28a Python version: 3.8.1

IndentationError - 1: expected an indented block

Python exception:
    IndentationError: expected an indented block

An IndentationError occurs when a given line of code is
not indented (aligned vertically with other lines) as expected.

Python could not understand the code in the file
'TESTS:\syntax\raise_indentation_error1.py'
beyond the location indicated below by --> and ^.

   1: '''Should raise IndentationError'''
   2:
   3: if True:
-->4: pass
      ^

Likely cause based on the information given by Python:
    In this case, the line identified above
    was expected to begin a new indented block.

IndentationError - 2: unexpected indent

Python exception:
    IndentationError: unexpected indent

An IndentationError occurs when a given line of code is
not indented (aligned vertically with other lines) as expected.

Python could not understand the code in the file
'TESTS:\syntax\raise_indentation_error2.py'
beyond the location indicated below by --> and ^.

   1: '''Should raise IndentationError'''
   2: if True:
   3:     pass
-->4:       pass
           ^

Likely cause based on the information given by Python:
    In this case, the line identified above
    is more indented than expected and
    does not match the indentation of the previous line.

IndentationError - 3: unindent does not match …

Python exception:
    IndentationError: unindent does not match any outer indentation level

An IndentationError occurs when a given line of code is
not indented (aligned vertically with other lines) as expected.

Python could not understand the code in the file
'TESTS:\syntax\raise_indentation_error3.py'
beyond the location indicated below by --> and ^.

   1: '''Should raise IndentationError'''
   2: if True:
   3:       pass
-->4:     pass
              ^

Likely cause based on the information given by Python:
    In this case, the line identified above is
    less indented than the preceding one,
    and is not aligned vertically with another block of code.

TabError

Python exception:
    TabError: inconsistent use of tabs and spaces in indentation

A TabError indicates that you have used both spaces
and tab characters to indent your code.
This is not allowed in Python.
Indenting your code means to have block of codes aligned vertically
by inserting either spaces or tab characters at the beginning of lines.
Python's recommendation is to always use spaces to indent your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_tab_error.py'
beyond the location indicated below by --> and ^.

    4:
    5: def test_tab_error():
    6:     if True:
--> 7:      pass
            ^

SyntaxError - Assign to keyword

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error1.py'
beyond the location indicated below by --> and ^.

   1: """ Should raise SyntaxError"""
   2:
-->3: def = 2
          ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    You were trying to assign a value to the Python keyword 'def'.
    This is not allowed.

SyntaxError - Missing colon - 1

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error2.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError"""
   2:
-->3: if True
             ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    You wrote a statement beginning with
    'if' but forgot to add a colon ':' at the end

SyntaxError - Missing colon - 2

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error3.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError"""
   2:
-->3: while True  # a comment
                  ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    You wrote a 'while' loop but
    forgot to add a colon ':' at the end

SyntaxError - elif, not else if

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error4.py'
beyond the location indicated below by --> and ^.

   2:
   3: if False:
   4:     pass
-->5: else if True:
           ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    You meant to use Python's 'elif' keyword
    but wrote 'else if' instead

SyntaxError - elif, not elseif

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error5.py'
beyond the location indicated below by --> and ^.

   2:
   3: if False:
   4:     pass
-->5: elseif True:
             ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    You meant to use Python's 'elif' keyword
    but wrote 'elseif' instead

SyntaxError - malformed def statment - 1

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error6.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError"""
   2:
-->3: def :
          ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    You tried to define a function or method and did not use the correct syntax.
    The correct syntax is:
        def name ( optional_arguments ):

SyntaxError - malformed def statment - 2

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error7.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError"""
   2:
-->3: def name  :
                ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    You tried to define a function or method and did not use the correct syntax.
    The correct syntax is:
        def name ( optional_arguments ):

SyntaxError - malformed def statment - 3

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error8.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError"""
   2:
-->3: def ( arg )  :
          ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    You tried to define a function or method and did not use the correct syntax.
    The correct syntax is:
        def name ( optional_arguments ):

SyntaxError - can’t assign to literal - 1

Python exception:
    SyntaxError: cannot assign to literal

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error9.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: can't assign to literal"""
   2:
-->3: 1 = a
      ^

Likely cause based on the information given by Python:
    You wrote an expression like
        1 = a
    where <1>, on the left-hand side of the equal sign,
    is or includes an actual object of type 'int'
    and is not simply the name of a variable. Perhaps you meant to write:
        a = 1

SyntaxError - can’t assign to literal - 2

Python exception:
    SyntaxError: cannot assign to literal

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error10.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: can't assign to literal"""
   2:
-->3: 1 = 2
      ^

Likely cause based on the information given by Python:
    You wrote an expression like
        1 = 2
    where <1>, on the left-hand side of the equal sign,
    is or includes an actual object of type 'int'
    and is not simply the name of a variable.

SyntaxError - can’t assign to literal - 3

Python exception:
    SyntaxError: cannot assign to set display

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error52.py'
beyond the location indicated below by --> and ^.

    4:
    5:  """
    6:
--> 7: {1, 2, 3} = 4
       ^

Likely cause based on the information given by Python:
    You wrote an expression like
        {1, 2, 3} = 4
    where <{1, 2, 3}>, on the left-hand side of the equal sign,
    is or includes an actual object of type 'set'
    and is not simply the name of a variable.

SyntaxError - can’t assign to literal - 4

Python exception:
    SyntaxError: cannot assign to dict display

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error53.py'
beyond the location indicated below by --> and ^.

    4:
    5:  """
    6:
--> 7: {1 : 2, 2 : 4} = 5
       ^

Likely cause based on the information given by Python:
    You wrote an expression like
        {1 : 2, 2 : 4} = 5
    where <{1 : 2, 2 : 4}>, on the left-hand side of the equal sign,
    is or includes an actual object of type 'dict'
    and is not simply the name of a variable.

SyntaxError - can’t assign to literal - 5

Python exception:
    SyntaxError: cannot assign to literal

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error54.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: can't assign to literal
   2: or (Python 3.8) cannot assign to literal"""
   3:
-->4: 1 = a = b
      ^

Likely cause based on the information given by Python:
    You wrote an expression like
        ... = variable_name
    where <...>, on the left-hand side of the equal sign,
    is or includes an actual object
    and is not simply the name of a variable.

SyntaxError - import X from Y

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error11.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: invalid syntax"""
   2:
-->3: import pen from turtle
                 ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    You wrote something like
        import pen from turtle
    instead of
        from turtle import pen

SyntaxError - EOL while scanning string literal

Python exception:
    SyntaxError: EOL while scanning string literal

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error12.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: EOL while scanning string literal"""
   2:
-->3: alphabet = 'abc
                     ^

Likely cause based on the information given by Python:
    You starting writing a string with a single or double quote
    but never ended the string with another quote on that line.

SyntaxError - assignment to keyword (None)

Python exception:
    SyntaxError: cannot assign to None

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error13.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: cannot assign to None in Py 3.8
   2:    and can't assign to keyword before."""
   3:
-->4: None = 1
      ^

Likely cause based on the information given by Python:
    None is a constant in Python; you cannot assign it a value.

SyntaxError - assignment to keyword (__debug__)

Python exception:
    SyntaxError: cannot assign to __debug__

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error14.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: cannot assign to __debug__ in Py 3.8
   2:    and assignment to keyword before."""
   3:
-->4: __debug__ = 1
      ^

Likely cause based on the information given by Python:
    __debug__ is a constant in Python; you cannot assign it a value.

SyntaxError - unmatched closing parenthesis

Python exception:
    SyntaxError: unmatched ')'

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error15.py'
beyond the location indicated below by --> and ^.

   3: """
   4: a = (1,
   5:     2,
-->6:     3, 4,))
                ^

Likely cause based on the information given by Python:
    The closing parenthesis ')' on line 6 does not match anything.

SyntaxError - unclosed parenthesis- 1

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error16.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: invalid syntax"""
   2: x = int('1'
-->3: if x == 1:
               ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    The opening parenthesis '(' on line 2 is not closed.

        2: x = int('1'
                  ^

SyntaxError - unclosed parenthesis - 2

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error17.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: invalid syntax"""
   2: a = (b+c
-->3: d = a*a
      ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    The opening parenthesis '(' on line 2 is not closed.

        2: a = (b+c
               ^

SyntaxError - mismatched brackets

Python exception:
    SyntaxError: closing parenthesis ']' does not match opening parenthesis '('

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error18.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: invalid syntax"""
-->2: x = (1, 2, 3]
                  ^

Likely cause based on the information given by Python:
    Python tells us that the closing ']' on the last line shown
    does not match the opening '('.

    I will attempt to be give a bit more information.

    The closing square bracket ']' on line 2 does not match the opening parenthesis '(' on line 2.

        2: x = (1, 2, 3]
               ^       ^

SyntaxError - mismatched brackets - 2

Python exception:
    SyntaxError: closing parenthesis ']' does not match opening parenthesis '(' on line 2

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error19.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: invalid syntax"""
   2: x = (1,
   3:      2,
-->4:      3]
            ^

Likely cause based on the information given by Python:
    Python tells us that the closing ']' on the last line shown
    does not match the opening '(' on line 2.

    I will attempt to be give a bit more information.

    The closing square bracket ']' on line 4 does not match the opening parenthesis '(' on line 2.

        2: x = (1,
               ^
        4:      3]
                 ^

SyntaxError - print is a function

Python exception:
    SyntaxError: Missing parentheses in call to 'print'. Did you mean print('hello')?

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error20.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: Missing parentheses in call to 'print' ..."""
-->2: print 'hello'
            ^

Likely cause based on the information given by Python:
    Perhaps you need to type print('hello')?

    In older version of Python, 'print' was a keyword.
    Now, 'print' is a function; you need to use parentheses to call it.

SyntaxError - Python keyword as function name

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error21.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: invalid syntax"""
   2:
-->3: def pass():
          ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    You tried to use the Python keyword 'pass' as a function name.

SyntaxError - break outside loop

Python exception:
    SyntaxError: 'break' outside loop

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error22.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: 'break' outside loop"""
   2:
   3: if True:
-->4:     break
          ^

Likely cause based on the information given by Python:
    The Python keyword 'break' can only be used inside a for loop or inside a while loop.

SyntaxError - continue outside loop

Python exception:
    SyntaxError: 'continue' not properly in loop

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error23.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: 'continue' outside loop"""
   2:
   3: if True:
-->4:     continue
          ^

Likely cause based on the information given by Python:
    The Python keyword 'continue' can only be used inside a for loop or inside a while loop.

SyntaxError - quote inside a string

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error24.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: invalid syntax"""
   2:
-->3: message = 'don't'
                     ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    There appears to be a Python identifier (variable name)
    immediately following a string.
    I suspect that you were trying to use a quote inside a string
    that was enclosed in quotes of the same kind.

SyntaxError - missing comma in a dict

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error25.py'
beyond the location indicated below by --> and ^.

   2:
   3: a = {'a': 1,
   4:      'b': 2
-->5:      'c': 3,
           ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    It is possible that you forgot a comma between items in a set or dict
    before the position indicated by --> and ^.

SyntaxError - missing comma in a set

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error26.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: invalid syntax"""
   2:
-->3: a = {1, 2  3}
                 ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    It is possible that you forgot a comma between items in a set or dict
    before the position indicated by --> and ^.

SyntaxError - missing comma in a list

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error27.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: invalid syntax"""
   2:
-->3: a = [1, 2  3]
                 ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    It is possible that you forgot a comma between items in a list
    before the position indicated by --> and ^.

SyntaxError - missing comma in a tuple

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error28.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: invalid syntax"""
   2:
-->3: a = (1, 2  3)
                 ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    It is possible that you forgot a comma between items in a tuple,
    or between function arguments,
    before the position indicated by --> and ^.

SyntaxError - missing comma between function args

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error29.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: invalid syntax"""
   2:
   3:
-->4: def a(b, c d):
                 ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    It is possible that you forgot a comma between items in a tuple,
    or between function arguments,
    before the position indicated by --> and ^.

SyntaxError - can’t assign to function call - 1

Python exception:
    SyntaxError: cannot assign to function call

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error30.py'
beyond the location indicated below by --> and ^.

   3: Python 3.8: SyntaxError: cannot assign to function call
   4: """
   5:
-->6: len('a') = 3
      ^

Likely cause based on the information given by Python:
    You wrote the expression
        len('a') = 3
    where len('a'), on the left-hand side of the equal sign, either is
    or includes a function call and is not simply the name of a variable.

SyntaxError - can’t assign to function call - 2

Python exception:
    SyntaxError: cannot assign to function call

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error31.py'
beyond the location indicated below by --> and ^.

   3: Python 3.8: SyntaxError: cannot assign to function call
   4: """
   5:
-->6: func(a, b=3) = 4
      ^

Likely cause based on the information given by Python:
    You wrote an expression like
        my_function(...) = some value
    where my_function(...), on the left-hand side of the equal sign, is
    a function call and not the name of a variable.

SyntaxError - used equal sign instead of colon

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error32.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: invalid syntax
   2: """
   3:
-->4: ages = {'Alice'=22, 'Bob'=24}
                     ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    It is possible that you used an equal sign '=' instead of a colon ':'
    to assign values to keys in a dict
    before or at the position indicated by --> and ^.

SyntaxError - non-default argument follows default argument

Python exception:
    SyntaxError: non-default argument follows default argument

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error33.py'
beyond the location indicated below by --> and ^.

   2: """
   3:
   4:
-->5: def test(a=1, b):
               ^

Likely cause based on the information given by Python:
    In Python, you can define functions with only positional arguments

        def test(a, b, c): ...

    or only keyword arguments

        def test(a=1, b=2, c=3): ...

    or a combination of the two

        def test(a, b, c=3): ...

    but with the keyword arguments appearing after all the positional ones.
    According to Python, you used positional arguments after keyword ones.

SyntaxError - positional argument follows keyword argument

Python exception:
    SyntaxError: positional argument follows keyword argument

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error34.py'
beyond the location indicated below by --> and ^.

   2: """
   3:
   4:
-->5: test(a=1, b)
                ^

Likely cause based on the information given by Python:
    In Python, you can call functions with only positional arguments

        test(1, 2, 3)

    or only keyword arguments

        test(a=1, b=2, c=3)

    or a combination of the two

        test(1, 2, c=3)

    but with the keyword arguments appearing after all the positional ones.
    According to Python, you used positional arguments after keyword ones.

SyntaxError - f-string: unterminated string

Python exception:
    SyntaxError: f-string: unterminated string

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error35.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: f-string: unterminated string
   2: """
   3:
-->4: print(f"Bob is {age['Bob]} years old.")
            ^

Likely cause based on the information given by Python:
    Inside an f-string, which is a string prefixed by the letter f,
    you have another string, which starts with either a
    single quote (') or double quote ("), without a matching closing one.

SyntaxError - unclosed bracket

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error36.py'
beyond the location indicated below by --> and ^.

    4: def foo():
    5:     return [1, 2, 3
    6:
--> 7: print(foo())
       ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    The opening square bracket '[' on line 5 is not closed.

        5:     return [1, 2, 3
                      ^

SyntaxError - unexpected EOF while parsing

Python exception:
    SyntaxError: unexpected EOF while parsing

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code the file
'TESTS:\syntax\raise_syntax_error37.py'.
It reached the end of the file and expected more content.

    5:     return [1, 2, 3,
    6:
    7: print(foo())

Likely cause based on the information given by Python:
    Python tells us that the it reached the end of the file
    and expected more content.

    I will attempt to be give a bit more information.

    The opening square bracket '[' on line 5 is not closed.

        5:     return [1, 2, 3,
                      ^

SyntaxError - name is parameter and global

Python exception:
    SyntaxError: name 'x' is parameter and global

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error38.py'
beyond the location indicated below by --> and ^.

   3:
   4:
   5: def f(x):
-->6:     global x
          ^

Likely cause based on the information given by Python:
    You are including the statement

            global x

    indicating that 'x' is a variable defined outside a function.
    You are also using the same 'x' as an argument for that
    function, thus indicating that it should be variable known only
    inside that function, which is the contrary of what 'global' implied.

SyntaxError - keyword as attribute

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error39.py'
beyond the location indicated below by --> and ^.

    9: a = A()
   10:
   11: a.x = 1
-->12: a.pass = 2
         ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    You cannot use the Python keyword pass as an attribute.

SyntaxError - content passed continuation line character

Python exception:
    SyntaxError: unexpected character after line continuation character

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error40.py'
beyond the location indicated below by --> and ^.

   2: SyntaxError: unexpected character after line continuation character
   3: """
   4:
-->5: print(\t)
               ^

Likely cause based on the information given by Python:
    You are using the continuation character '\' outside of a string,
    and it is followed by some other character(s).
    I am guessing that you forgot to enclose some content in a string.

SyntaxError - keyword can’t be an expression

Python exception:
    SyntaxError: expression cannot contain assignment, perhaps you meant "=="?

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error41.py'
beyond the location indicated below by --> and ^.

    4: """
    5:
    6:
--> 7: a = dict('key'=1)
                ^

Likely cause based on the information given by Python:
    One of the following two possibilities could be the cause:
    1. You meant to do a comparison with == and wrote = instead.
    2. You called a function with a named argument:

           a_function(invalid=something)

    where 'invalid' is not a valid variable name in Python
    either because it starts with a number, or is a string,
    or contains a period, etc.

SyntaxError - invalid character in identifier

Python exception:
    SyntaxError: invalid character in identifier

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error42.py'
beyond the location indicated below by --> and ^.

   3:
   4: # Robot-face character below
   5:
-->6: 🤖 = 'Reeborg'
      ^

Likely cause based on the information given by Python:
    You likely used some unicode character that is not allowed
    as part of a variable name in Python.
    This includes many emojis.

SyntaxError - keyword cannot be argument in def - 1

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error43.py'
beyond the location indicated below by --> and ^.

   2: """
   3:
   4:
-->5: def f(None=1):
            ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    I am guessing that you tried to use the Python keyword
    None as an argument in the definition of a function.

SyntaxError - keyword cannot be argument in def - 2

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error44.py'
beyond the location indicated below by --> and ^.

   2: """
   3:
   4:
-->5: def f(x, True):
               ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    I am guessing that you tried to use the Python keyword
    True as an argument in the definition of a function.

SyntaxError - keyword cannot be argument in def - 3

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error45.py'
beyond the location indicated below by --> and ^.

   2: """
   3:
   4:
-->5: def f(*None):
             ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    I am guessing that you tried to use the Python keyword
    None as an argument in the definition of a function.

SyntaxError - keyword cannot be argument in def - 4

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error46.py'
beyond the location indicated below by --> and ^.

   2: """
   3:
   4:
-->5: def f(**None):
              ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    I am guessing that you tried to use the Python keyword
    None as an argument in the definition of a function.

SyntaxError - delete function call

Python exception:
    SyntaxError: cannot delete function call

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error47.py'
beyond the location indicated below by --> and ^.

   2: """
   3:
   4:
-->5: del f(a)
          ^

Likely cause based on the information given by Python:
    You attempted to delete a function call
        del f(a)
    instead of deleting the function's name
        del f

SyntaxError - assigned prior to global declaration

Python exception:
    SyntaxError: name 'p' is assigned to before global declaration

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error48.py'
beyond the location indicated below by --> and ^.

    4:
    5: def fn():
    6:     p = 1
--> 7:     global p
           ^

Likely cause based on the information given by Python:
    You assigned a value to the variable 'p'
    before declaring it as a global variable.

SyntaxError - used prior to global declaration

Python exception:
    SyntaxError: name 'r' is used prior to global declaration

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error49.py'
beyond the location indicated below by --> and ^.

    4:
    5: def fn():
    6:     print(r)
--> 7:     global r
           ^

Likely cause based on the information given by Python:
    You used the variable 'r'
    before declaring it as a global variable.

SyntaxError - assigned prior to nonlocal declaration

Python exception:
    ModuleNotFoundError: No module named 'raise_syntax_error5-'

A ModuleNotFoundError exception indicates that you
are trying to import a module that cannot be found by Python.
This could be because you misspelled the name of the module
or because it is not installed on your computer.

Likely cause based on the information given by Python:
    In your program, the name of the
    module that cannot be found is 'raise_syntax_error5-'.

Execution stopped on line 114 of file 'TESTS:\trb_syntax_common.py'.

   112:                 make_title(title)
   113:                 try:
-->114:                     mod = __import__(name)

name: 'raise_syntax_error5-'

SyntaxError - used prior to nonlocal declaration

Python exception:
    SyntaxError: name 's' is assigned to before nonlocal declaration

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error51.py'
beyond the location indicated below by --> and ^.

    6:
    7:     def g():
    8:         s = 2
--> 9:         nonlocal s
               ^

Likely cause based on the information given by Python:
    You assigned a value to the variable 's'
    before declaring it as a nonlocal variable.

SyntaxError - named assignment with Python constant

Python exception:
    SyntaxError: cannot use named assignment with True

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error55.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: invalid syntax
   2: or (Python 3.8) cannot use named assignment with True"""
   3:
-->4: (True := 1)
       ^

Likely cause based on the information given by Python:
    True is a constant in Python; you cannot assign it a value.

SyntaxError - assignment to operator

Python exception:
    SyntaxError: cannot assign to operator

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error56.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: can't assign to operator
   2: or (Python 3.8) cannot assign to operator"""
   3:
-->4: a + 1 = 2
      ^

Likely cause based on the information given by Python:
    You wrote an expression that includes some mathematical operations
    on the left-hand side of the equal sign which should be
    only used to assign a value to a variable.

SyntaxError - using the backquote character

Python exception:
    SyntaxError: invalid syntax

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error57.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: invalid syntax"""
   2:
-->3: a = `1`
          ^

I don't have enough information from Python:
    I make an effort below to guess what caused the problem
    but I might guess incorrectly.

    You are using the backquote character `.
    This was allowed in Python 2 but is no longer allowed.
    Use the function repr(x) instead of `x`.

SyntaxError - assign to generator expression

Python exception:
    SyntaxError: cannot assign to generator expression

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error58.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: can't [cannot] assign to generator expression"""
   2:
-->3: (x for x in x) = 1
      ^

Likely cause based on the information given by Python:
    On the left-hand side of an equal sign, you have a
    generator expression instead of the name of a variable.

SyntaxError - assign to conditional expression

Python exception:
    SyntaxError: cannot assign to conditional expression

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error59.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: can't [cannot] assign to conditional expression"""
   2:
-->3: a if 1 else b = 1
      ^

Likely cause based on the information given by Python:
    On the left-hand side of an equal sign, you have a
    conditional expression instead of the name of a variable.
    A conditional expression has the following form:

        variable = object if condition else other_object

SyntaxError - name is parameter and nonlocal

Python exception:
    SyntaxError: name 'x' is parameter and nonlocal

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error60.py'
beyond the location indicated below by --> and ^.

   2:
   3:
   4: def f(x):
-->5:     nonlocal x
          ^

Likely cause based on the information given by Python:
    You used 'x' as a parameter for a function
    before declaring it also as a nonlocal variable:
    'x' cannot be both at the same time.

SyntaxError - name is global and nonlocal

Python exception:
    SyntaxError: name 'xy' is nonlocal and global

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error61.py'
beyond the location indicated below by --> and ^.

    4:
    5:
    6: def f():
--> 7:     global xy
           ^

Likely cause based on the information given by Python:
    You declared 'xy' as being both a global and nonlocal variable.
    A variable can be global, or nonlocal, but not both at the same time.

SyntaxError - nonlocal variable not found

Python exception:
    SyntaxError: no binding for nonlocal 'ab' found

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error62.py'
beyond the location indicated below by --> and ^.

   2:
   3:
   4: def f():
-->5:     nonlocal ab
          ^

Likely cause based on the information given by Python:
    You declared the variable 'ab' as being a
    nonlocal variable but it cannot be found.

SyntaxError - nonlocal variable not found at module level

Python exception:
    SyntaxError: nonlocal declaration not allowed at module level

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error63.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError:  nonlocal declaration not allowed at module level"""
   2:
   3:
-->4: nonlocal cd
      ^

Likely cause based on the information given by Python:
    You used the nonlocal keyword at a module level.
    The nonlocal keyword refers to a variable inside a function
    given a value outside that function.

SyntaxError - keyword arg only once in function definition

Python exception:
    SyntaxError: duplicate argument 'aa' in function definition

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error64.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError: duplicate argument 'aa' in function definition"""
   2:
   3:
-->4: def f(aa=1, aa=2):
      ^

Likely cause based on the information given by Python:
    You have defined a function repeating the keyword argument
        'aa'
    twice; each keyword argument should appear only once in a function definition.

SyntaxError - keyword arg only once in function call

Python exception:
    SyntaxError: keyword argument repeated

A SyntaxError occurs when Python cannot understand your code.

Python could not understand the code in the file
'TESTS:\syntax\raise_syntax_error65.py'
beyond the location indicated below by --> and ^.

   1: """Should raise SyntaxError:  keyword argument repeated"""
   2:
   3:
-->4: f(ad=1, ad=2)
              ^

Likely cause based on the information given by Python:
    You have called a function repeating the same keyword argument.
    Each keyword argument should appear only once in a function call.