The average video watch time
Code review · Medium · §8.5 Inside and outside a function
This code is meant to return the average of a list of watch times (in minutes). It runs without an error and the first printed line is right, but the second printed line looks wrong. Fix just one place so that the output is 30.0 and 15.0.
Code to fix
def average(times):
total = 0
for t in minutes:
total += t
return total / len(times)
minutes = [20, 30, 40]
print(average(minutes))
print(average([10, 20]))Solve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.