318-8 Conditional Statements help

https://app.dataquest.io/m/313/conditional-statements/8/comparison-operators

Dear Support, I need your help to understand this part :joy:

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

Why is the 1, 7 and 4 being introducedā€¦and what does apps_data[1:] stand for in the context of this task. Thank you in advance

Hi @mokayamakori2050, welcome to the community!

Indexing lists is introduced in a previous mission about lists and loops. You may want to go back and review that mission (all the screens), since indexing plays a very important role when working with datasets.

For the screen youā€™re working on, youā€™re creating a loop that will cycle through all the rows in the dataset apps_data, excluding the first row (which is at index 0). apps_data[1:] represents all the rows except the first one. Inside the loop, weā€™re extracting the information is at the 7th and 4th index of that row, hence row[7] and row[4]. I think it helps to think of the dataset as a grid, with rows and columns. Your loop will allow you to look at one row at a time, and then when weā€™ve isolated the row, we take the information in a specific column of that row.

I hope that helps clarify things for you!

1 Like

Thank you for your clarification.

Hey, I canā€™t get past If statements (1/12) from Conditional Statementsā€¦ Can someone enlighten me?
The code offered as solution has the following output:

TypeErrorTraceback (most recent call last)
in ()
12 free_apps_ratings.append(rating)
13
ā€”> 14 avg_rating_free = sum(free_apps_ratings) / len(free_apps_ratings)

When I try to submit the answer the reply is:

  • Running your code caused an error.
  • avg_rating_free is a int, but we expected it to be a float.
  • avg_rating_free is less than what we expected.

INITIAL CODE

opened_file = open(ā€˜AppleStore.csvā€™)
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)

free_apps_ratings =
for row in apps_data[1:]:
rating = float(row[7])
# Complete the code from here

SOLUTION CODE

free_apps_ratings =
for row in apps_data[1:]:
rating = float(row[7])
# Complete the code from here
price = float(row[4])
if price == 0.0:
free_apps_ratings.append(rating)

avg_rating_free = sum(free_apps_ratings) / len(free_apps_ratings)

I sincerely appreciate if someone is able to help me :slight_smile: