Screen Link:
https://app.dataquest.io/m/312/lists-and-for-loops/11/alternative-way-to-compute-an-average
My Code:
opened_file = open('AppleStore.csv')
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)
all_ratings = []
for each_row in apps_data[1:]:
rating = float(each_row[7])
all_ratings.append(rating)
avg_rating = sum(all_ratings) / len(all_ratings)
print(avg_rating)
What I expected to happen:
Run properly
What actually happened:
TypeErrorTraceback (most recent call last)
<ipython-input-1-4e003632f9ff> in <module>()
9 all_ratings.append(rating)
10
---> 11 avg_rating = sum(all_ratings) / len(all_ratings)
12 print(avg_rating)
TypeError: 'int' object is not callable
Can someone please explain to me what I did wrong here? When I copied and pasted in the correct answer, the code ran properly, even though my own code is identical to the given answer. Thanks!