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.

  1. Read what the AI wrote

  2. Spot the broken line

  3. Ship it, or send it back

Some of the code is fine.

0 of 10 reviewed

1. Average of a list

Easy

You 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)