Workspace / Investigation details
SAMPLE INVESTIGATION

An empty list breaks the average

Python · 2026-11-10 · sample-python

New Investigation
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 zero

Suspected 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.py

Verification status

Not Tested

Illustrative 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
Suggested code fix · illustrative onlyUNVERIFIED
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

  1. Source context added

    statistics.py and the error message.

  2. Explanation drafted

    Hand-written demo root cause and proposed patch.

  3. Verification pending

    No code has been executed or tested.