SAMPLE INVESTIGATION
An empty list breaks the average
Python · 2026-11-10 · sample-python
Sample report · Hand-written demonstration only. No AI analysis or tests were performed on this example.
Investigation summary
This hand-written example demonstrates a debugging report. No AI analysis has been performed.
Error description
ZeroDivisionError: division by zeroSuspected root cause · sample
The function divides by the list length without checking whether the list is empty. Define the empty-input contract before computing the average.
Related files
statistics.pyVerification status
Not TestedIllustrative patch only. No static checks or tests have been run on this sample.
Verification state reference
Design examples below are not results for this investigation.
Not TestedStatic Check PassedStatic Check FailedTest VerifiedTest FailedVerification Unavailable
ORIGINAL · statistics.py
def average(values):
return sum(values) / len(values)
print(average([]))SUGGESTED · statistics.py
def average(values):
if not values:
raise ValueError("Expected at least one value")
return sum(values) / len(values)Reject empty input explicitly with a meaningful error.
Investigation timeline SAMPLE
- Source context added
statistics.py and the error message.
- Explanation drafted
Hand-written demo root cause and proposed patch.
- Verification pending
No code has been executed or tested.