Mission 7 issues "conditional statements

Screen Link:

My Code:

"""debug = []
nonfree_games_social_ratings = []
for row in apps_data[1:]:
    debug.append(row)
    rating = float(row[7])
    genre = row[11]
    price = float(row[4]
                  
    if (genre == 'Social Networking' or genre == 'Games') and price != 0:
        nonfree_games_social_ratings.append(rating)

ave_non_free = sum(nonfree_games_social_ratings) / len(nonfree_games_social_ratings)
         

What I expected to happen:

What actually happened:

 File "<ipython-input-1-4875c8580010>", line 25
    if (genre == 'Social Networking' or genre == 'Games') and price != 0:
                                                                        ^
SyntaxError: invalid syntax

This is similar to my code.

@KhaledHanafy

Close the parenthesis here:

didn’t catch that. well done.

1 Like

Try this

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

non_free_games_social_ratings = []
for row in apps_data[1:]:
    rating = float(row[7])
    genre = row[11]
    price = float(row[4])
    
    if (genre == 'Social Networking' or genre == 'Games') and price != 0:
        non_free_games_social_ratings.append(rating)
        
avg_non_free = sum(non_free_games_social_ratings) / len(non_free_games_social_ratings)

thank you my brother, i figured it out.

1 Like

ave instead of avg?