Exception Attributes

SyntaxError.end_lineno — exception attribute

Inspect the reported ending line of a syntax error range. Like lineno, it is one-based when supplied. A missing end location does not imply that the error spans a single character.

Formal Syntax & Structure

python syntaxpython
error.end_lineno

Return Value

int | None

Diagnostic field when available.

Working Example

Example Snippetpython
error = SyntaxError("expected expression", ("demo.py", 3, 5, "x = ?\n", 3, 6))print(error.end_lineno)
Python Reference