An AI assistant drafted the average function below. It runs on a normal list, but the acceptance checks fail.
Your job is the one an engineer actually does with AI-written code: work out what it got wrong, and fix it.
Two behaviours are wrong:
- The average of [1, 2] comes out as 1 instead of 1.5 (the decimal is being dropped).
- An empty list crashes instead of returning 0.
Press Run to see the checks fail, then fix average so all of them pass. Keep the function signature unchanged.
You have an AI assistant available. Use it however you normally would - how you direct it and whether you check its answers is part of what we look at.