#209 · Lists · Beginner · 30 XP · about 5 min
Write above_average(nums) that returns the numbers in nums that are strictly greater than the average of the list, in the order they appear. The average is the sum of the numbers divided by how many there are.
A number equal to the average is not above it. An empty list gives an empty list.
above_average([1, 2, 3, 4, 5]) # returns [4, 5] above_average([3, 9, 1, 7]) # returns [9, 7] above_average([10, 10, 10]) # returns []
In the second example the average is 20 / 4 = 5, and 9 and 7 are the numbers above it.
nums holds whole numbers, which may be negative.
First solves only, ranked by stars and then time.