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

The average rating is not as expected and also the length of the list is shorter than expected

Screen Link:
https://app.dataquest.io/c/57/m/313/conditional-statements/6/the-or-operator

My Code:

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

games_social_ratings = []
for row in apps_data[1:]:
    rating = float(row[7])
    genre = row[11]
    
    if genre == 'Socal Networking' or genre == 'Games':
        games_social_ratings.append(rating)
        
avg_games_social = sum(games_social_ratings) / len(games_social_ratings)
print(avg_games_social)

What I expected to happen:
I expected that the code I ran would be equal to the actual average rating.

What actually happened:

avg_games_social is greater than what we expected.
games_social_ratings is shorter than we expected.

Hi there!

I am not sure as to why the output of my code is not what is expected. I even cross-checked it with the solution given by DQ.

If anyone can help, thank you in advance. :slight_smile:

You have a typo in Socal.

1 Like

Oh shoot! Silly me! Thanks doctor!