Problem in conditional statement section

Screen Link:

My Code:

opened_file = open('AppleStore.csv')
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)
for row in apps_data[1:]:
    if genre!='Games':

What I couldn’t understand:
Why do we use row[7] for assigning the ratings.We know that indexing starts from 0.So,shouldn’t it be row [6]

Here’s the screen snip

These are the column names along with their indices -

  1. id
  2. track_name
  3. size_bytes
  4. currency
  5. price
  6. rating_count_tot
  7. rating_count_ver
  8. user_rating

As you can see, row[7] would correspond to user_rating.

Why do we write if statement inside the for loop?
I tried writing the if statement outside the for loop but that affects the output. I get the output as 0 when if statement is written outside the for loop. Why?

Please ask your question in a separate/new post. Best to have a separate post for every question.

1 Like