opened_file = open(‘AppleStore.csv’)
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)
rating_sum = 0
for row in apps_data[1:]:
rating = float(row)
rating_sum += rating
avg_rating = rating_sum / len(apps_data[1:])
TypeErrorTraceback (most recent call last)
2 from csv import reader
3 read_file = reader(opened_file)
----> 4 apps_data = list(read_file)
5 rating_sum = 0
6 for row in apps_data[1:]:
TypeError: ‘list’ object is not callable
Also showing(dataquest console):
- Running your code caused an error.
- avg_rating isn’t defined in your code, but we expected it to be float type
Your code is correct and should work. It sounds like you might have used the keyword
list as a variable name somewhere else in a previous screen in the same mission. You can read this post by @joshdq for more details.
i think you missed indentation in the body of for loop
That would not explain why he got a TypeError.
yeah…you’re right…I was using list as an iterable in a previous screen…thanks…
@Mary Maybe the Variables And Data Types Mission in the Python Fundamentals course could be updated to include the info that Python keywords should not be used as variable names? Several users seem to have found this out the hard way.
I’ll pass this along to our content team, @Slavina!