Blue Week Special Offer | Brighten your week!
days
hours
minutes
seconds

Type cast error while the answer is the same as the one provided

Hi,
I’m getting a TypeError with my submitted code below although it’s similar to the answer provided .
Did i missed something or is it a bug?
I commented the working alternative solution

Screen Link: https://app.dataquest.io/m/313/conditional-statements/8/comparison-operators

My Code:

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

rating_apps_price_more_9 = []
#n_apps_less_9 = 0
for app in apps_data[1:]:
    rating = float(app[7])
    price = float(app[4])
    if price > 9:
       rating_apps_price_more_9.append(rating)
    #if price <= 9:
    #    n_apps_less_9 +=1

avg_rating = sum(rating_apps_price_more_9)/len(rating_apps_price_more_9)
n_apps_more_9 = len(rating_apps_price_more_9)
n_apps_less_9 = len(apps_data[1:]) - len(n_apps_more_9)

What actually happened:

TypeErrorTraceback (most recent call last)
<ipython-input-1-15027fe4f1e7> in <module>()
     16 avg_rating = sum(rating_apps_price_more_9)/len(rating_apps_price_more_9)
     17 n_apps_more_9 = len(rating_apps_price_more_9)
---> 18 n_apps_less_9 = len(apps_data[1:]) - len(n_apps_more_9)

TypeError: object of type 'int' has no len()

n_apps_more_9 is an integer so there is no need of using len() just subtract len(apps[data[1:]) - n_apps_more_9 to get n_apps_less_9

Thanks ,indeed i did miss that !

n_apps_less_9 = len(apps_data[1:] - n_apps_more_9
still returns a traceback error
Here is what I have on my screen:
ratings_apps_pricemore_9=
for row in apps_data[1:]:
rating = float(row[7])
price = float (row[4])

if price > 9:
    ratings_apps_pricemore_9.append(rating)

avg_rating = sum(ratings_apps_pricemore_9) / len(ratings_apps_pricemore_9)
n_apps_more_9 =len(ratings_apps_pricemore_9)
n_apps_less_9 =len(apps_data[1:] - ratings_apps_pricemore_9.

Where have I gone wrong.Please help!!