Lists and for loops: alternative way to compute an average

Screen Link:
https://app.dataquest.io/m/312/lists-and-for-loops

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:
    all_ratings.append(float(row[7])
    
avg_rating = sum(all_ratings) / len(apps_data)
avg_rating                       

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