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

Please help,im stuck!, ERROR: ValueError: could not convert string to float: 'user_rating'

Screen Link: https://app.dataquest.io/m/313/conditional-statements/4/the-average-rating-of-gaming-apps

My Code:

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

non_games_ratings = []
for row in apps_data[1:]:
    rating = float(row[7])

    genre = row[11]
    if genre != 'Games':
        non_games_ratings.append(rating)

avg_rating_games = sum(non_games_ratings) / len(non_games_ratings)
print(avg_rating_non_games)

What I expected to happen:
to get the solution as mentioned

What actually happened: i received an error stating that ValueError: could not convert string to float: 'user_rating’

‘’’ OUTPUT ERROR:
<ValueError Traceback (most recent call last)
in
6 non_games_ratings =
7 for row in apps_data[1:]:
----> 8 rating = float(row[7])
9
10 genre = row[11]

ValueError: could not convert string to float: ‘user_rating’>


<!--Enter other details below: --> 
when i try to run the code it displays the above error, can you please explain whats wrong with my code, even though i checked the solution both are same . im so confused

Hi @moulee9494: In future, please format your code with 3 backticks [`] : below the Esc key on a US keyboard. Please try refreshing the mission.

1 Like

Hi I’m getting the same error. What does formatting like that mean? the code will not run due to the same error.

actually this is what I’m getting:


TypeError Traceback (most recent call last)
in
3 from csv import reader
4 read_file = reader(opened_file)
----> 5 apps_data = list(read_file)
6
7 free_games_ratings =

TypeError: ‘list’ object is not callable

Hi @moulee9494,

First of all, there is an issue in your code: in the penultimate line, you should assign not avg_rating_games, but avg_rating_non_games

You should do the following. First, restore the initial code of this mission screen (there is a round-arrow button “Restore Initial Code”, just to the right of the “Submit Answer” button). Then, insert your corrected code (you have to correct only this one issue). Finally, submit your answer, it should work fine now.