⛔ Syntax Error
5th Grade 💻 Coding
A syntax error is a mistake in how the code is written — a missing quotation mark, a parenthesis that was never closed, a forgotten colon — that keeps the computer from understanding the program, so it won’t run it.
In Python this kind of error is called a SyntaxError. For example, in print("Hello) the closing quotation mark is missing, so the computer doesn’t know where the text ends. The error message shows the line number, and sometimes a little arrow pointing roughly to where the problem is.
The good news: syntax errors are the easiest to find, because the computer finds them for you. Tip: if the line the computer points to looks fine, check the line before it too — sometimes a parenthesis that was opened there and never closed “spills over” into the next line.
For example
if x > 5with no colon at the end is a syntax error in Python.- Noah wrote
print(2 + 3and forgot to close the parenthesis; he added it — and the program ran. - Code editors color text inside quotation marks differently, so when a quote is missing, half the code suddenly changes color — a great clue.
📌 Remember: Syntax error = “I don’t understand what you wrote.” The computer shows you where.
Quick quiz
What is a syntax error?
What is a syntax error called in Python?
What is missing from the Python line if x > 5?