Skip to content
BENIBIX Learn

Runtime Error vs Logic Error

People think a program that runs to the end with no message is working, and it may not be. A runtime error stops the program while it runs and names the line, such as a divide by zero. A logic error stops nothing. The program finishes and the answer is just wrong. Only a check of the result will catch it.

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
Development🧩 Programming Concepts

Logic Error

Code that runs with no error message but gives the wrong answer.

A logic error is a mistake in the thinking behind the code. The program runs to the end with no message at all. It simply gives the wrong answer. Putting steps in the wrong order or using > where you meant >= are common causes. These are the hardest errors to find, because nothing tells you they are there.

Example
Emma writes a + b / 2 to average 4 and 6. It prints 7.0, because Python divides first. She needed (a + b) / 2.
Why it matters
Logic errors give wrong results that look right. Tests that check the answer, not just that it ran, catch them.
Full entry

In one line

Runtime Error
An error that shows up while the program runs. Some input sets it off.
Logic Error
Code that runs with no error message but gives the wrong answer.