NameError: name ‘app_data’ is not defined

@Sahil , kindly help out on this below :

opened_file = open('AppleStore.csv')
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)
all_ratings = []
for row in app_data[1:]:
    rating = float(row[7])
    all_ratings.append(rating)
    
avg_rating = sum(all_ratings)/len(all_ratings)
avg_rating
NameErrorTraceback (most recent call last)
<ipython-input-1-1b0a085fcd4f> in <module>()
      4 apps_data = list(read_file)
      5 all_ratings = []
----> 6 for row in app_data[1:]:
      7     rating = float(row[7])
      8     all_ratings.append(rating)

NameError: name 'app_data' is not defined

Hi @Oloyedesunday14,

NameError: name 'app_data' is not defined

This is due to a typo in your code:

----> 6 for row in app_data[1:]:

You are using app_data instead of apps_data which you have defined here:

apps_data = list(read_file)

Best,
Sahil

1 Like

The name apps_data was defined at the fourth line, but you call the name app_data at the 6th line…the difference is the ‘s’ at the back of app
Try this:
for row in apps_data[1:]:
Thanks
Ola

2 Likes

@Sahil … my eyes for details need to be strong enough…Thanks so much :+1:

1 Like

@olasunkanmiafolabi30 … Thanks bro. appreciate.