LIMITED TIME OFFER: 50% OFF OF PREMIUM WITH OUR ANNUAL PLAN (THAT'S $294 IN SAVINGS).
GET OFFER

“TypeError: 'list' object is not callable”

Hi,
under “Dictionaries and Frequency tables”/ “8. Finding the unique values”, I cannot run the pre-provided code; it returns the error: “TypeError: ‘list’ object is not callable”.

Screen Link: https://app.dataquest.io/m/314/dictionaries-and-frequency-tables/8/finding-the-unique-values

My Code:

opened_file = open('AppleStore.csv')
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)

content_ratings = {}
for list in apps_data[1:]:
   c_rating = list[10]
   if c_rating not in content_ratings:
       content_ratings[c_rating] = 1
   else:
       content_ratings[c_rating] += 1
       
print(content_ratings)

What actually happened:

TypeErrorTraceback (most recent call last)
<ipython-input-1-b1fe082a28c9> in <module>()
      2 from csv import reader
      3 read_file = reader(opened_file)
----> 4 apps_data = list(read_file)
      5 
      6 content_ratings = {}

TypeError: 'list' object is not callable

Other details:
I am not sure what I have done wrong… although on the previous slide “7. Counting with dictionaries”, I actually submitted the answer for “8. Finding the unique values”. As I had learnt the technique already, I applied it one slide earlier in 7. Perhaps this is what is causing the problem? I haven’t been unable to undo the error.

Wondering if you could please advise how to proceed?

Hey @rwon4926!

Check out this post and see if it helps:

3 Likes

Hi Mary,
Thank you so much for the redirection! It solved my problem.

I had used list as a name for a variable, and so, this overrode the default list() function. This change was made to the global scope, and stayed even when i reloaded my kernel.

To fix this, I used ‘’‘del list’’’, which restored the original list() function.

1 Like