Ship it?
Everyday Functions
Small helpers on numbers, text and lists. AI code often looks right but breaks on an empty input, a tie, or the very last item.
Read what the AI wrote
Spot the broken line
Ship it, or send it back
Some of the code is fine.
0 of 10 reviewed
1. Average of a list
EasyYou asked
Write average(nums): the mean of a list of numbers, or 0 for an empty list.
AI assistant
Here's a short, efficient solution that handles it.
1def average(nums):
2 return sum(nums) / len(nums)