Skip to content
BENIBIX Learn

Syntax Error vs Runtime Error

A syntax error stops the code before a single line runs. A runtime error waits until the code hits a bad value.

Development🧩 Programming Concepts

Syntax Error

Code that breaks the grammar rules of its language. Not one line of it runs.

A syntax error is code that breaks the grammar rules of its language. A missing bracket, a stray comma or a misspelled keyword are common causes. The computer cannot even read the program, so not one line runs. The message points to the line where it got confused. The real mistake is often on that line or the one just above it.

Example
Jack types if score > 10 and forgets the colon in Python. The program will not start until he adds it.
Why it matters
They are the easiest kind to fix. The computer tells you where they are.
Full entry
Development🧩 Programming Concepts

Runtime Error

An error that shows up while the program runs. Some input sets it off.

A runtime error happens while the program is running. The code is written right, so it starts. Then it hits something it cannot do. Dividing by zero, opening a file that is not there and using a null value are common causes. The program stops at that line and shows a message. Often it only happens with certain input, so it can hide for a long time.

Example
An average function works for weeks, then a class with no scores sends it an empty list. It crashes with ZeroDivisionError.
Why it matters
Runtime errors often reach real users, because they hide until odd input comes along. Testing edge cases finds them first.
Full entry

In one line

Syntax Error
Code that breaks the grammar rules of its language. Not one line of it runs.
Runtime Error
An error that shows up while the program runs. Some input sets it off.