Please help I am having difficulty understanding the code below

Please refer to the code in between the asterisk. I’m confused on exactly what it is doing here an the training doesn’t explain it very well. Is this taking the 7th element from the first row in the csv file?

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

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


avg_rating = sum(all_ratings)/len(all_ratings)

Hi @cmundell10, welcome to the community! It looks like you’re working on this mission.

In that middle section of code, we are using a loop and looking at one row at a time from apps_data. The [1:] part means we’re going through all the rows but the first one (apps_data[0]). Then from each row, we’re taking the element at the 7th index (so the 8th element) and adding it to the list all_ratings. When the loop is finished, we will have taken the ratings from each row of the dataset and put them in a separate list. This is basically the same thing as isolating all the values in one column.

Does that help at all?

1 Like

Great! @april.g yes that helped out immensely.

Thank you so much!


If this has resolved your question can you please mark April’s answer as solution so that it can help other learners. Thanks.

I am not sure how to mark it as the solution?

Hey @cmundell10

this will help you. :slight_smile: