Hi @klausuts welcome to the community!
ratingss variable from
apps_data[1:] is going to be a list of lists. Each row of the CSV becomes a list. Because each element is a list, or row,
ratingss[i] corresponds to one row of the dataset. So when you look at
ratingss, you’re looking at a particular row, not a particular column.
['512939461', 'Subway Surfers', '156038144', 'USD', '0.0', '706110', '97', '4.5', '4.0', '1.72.1', '9+', 'Games', '38', '5', '1', '1']
When you try to use
for c_rating in ratingss, it’s going to take each element of the
ratingss list above and see if it exists as a key in the
content_ratings dictionary. Once it’s finished looking at this one row, it stops because it wasn’t told to check any other rows of the dataset.
So now let’s look at the other code snippet where
ratingss is used differently. When you write
for ratingss in apps_data[1:]:, you go through each row of
apps_data and call that row
ratingss. Then you will take the 10th index of that row with
ratingss and assign it to the
c_rating variable. Once the if-statment runs and it updates the dictionary counts, it will go through the next row on until the end of the dataset.
To summarize, the difference between the 2 pieces of code is that when
ratingss was a list of lists,
ratingss meant the row at the 10th index. When
ratingss was just a single row, then
ratingss meant the value from the column you wanted in that row.
I hope that helps. Let me know if you need more clarification.