Lists and for loops: alternative way to compute an average

Screen Link:

My Code:

opened_file = open('AppleStore.csv')
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)
all_ratings = []
apps_data = apps_data[1:]
for row in apps_data:
avg_rating = sum(all_ratings) / len(apps_data)

What I expected to happen:

What actually happened:

 File "<ipython-input-1-4e1ca80627d3>", line 10
    avg_rating = sum(all_ratings) / len(apps_data)
SyntaxError: invalid syntax

The issue is actually with the code line above. You are missing a closing parenthesis ).

1 Like