# I don't understand why it's [-1] and not [4] and why both don't work

From my understanding I should count starting with 0, so the ratings here should be number [4]
row_1 = [‘Facebook’, 0.0, ‘USD’, 2974676, 3.5]

This is my code:

row_1 = [‘Facebook’, 0.0, ‘USD’, 2974676, 3.5]
row_2 = [‘Instagram’, 0.0, ‘USD’, 2161558, 4.5]
row_3 = [‘Clash of Clans’, 0.0, ‘USD’, 2130805, 4.5]
ratings_1 = row_1[4]
ratings_2 = row_2[4]
ratings_3 = row_3[4]
total = ratings_1 + ratings_2 + ratings_3
average = total/3

this what it tells me:
rating_1 isn’t defined in your code, but we expected it to be float type
rating_2 isn’t defined in your code, but we expected it to be float type
rating_3 isn’t defined in your code, but we expected it to be float type
total_rating isn’t defined in your code, but we expected it to be float type
average_rating isn’t defined in your code, but we expected it to be float type

and when I click “see the answer” this is the answer that is written:
row_1 = [‘Facebook’, 0.0, ‘USD’, 2974676, 3.5]
row_2 = [‘Instagram’, 0.0, ‘USD’, 2161558, 4.5]
row_3 = [‘Clash of Clans’, 0.0, ‘USD’, 2130805, 4.5]

rating_1 = row_1[-1]
rating_2 = row_2[-1]
rating_3 = row_3[-1]

total_rating = rating_1 + rating_2 + rating_3
average_rating = total_rating / 3

and even the answer that is written doesn’t work! it still tells me:
rating_1 isn’t defined in your code, but we expected it to be float type
rating_2 isn’t defined in your code, but we expected it to be float type
rating_3 isn’t defined in your code, but we expected it to be float type
total_rating isn’t defined in your code, but we expected it to be float type
average_rating isn’t defined in your code, but we expected it to be float type

I don’t understand why

could you help me out ?

1 Like

Hi @ar.ab.20600,

Welcome to the Community!

Just rename your variables in the same way as in the answer, e.g. instead of `ratings_1`, use `rating_1`, etc. Then, re-run your code, it should work smoothly now.

1 Like

Ah, and using negative indices to select items from a list is just an alternative to selecting data with “normal” indexing: -1 to select the last item, -2 to select the second to the last, etc.

1 Like

Actually I also had the similar confusion while I was there. It just doesn’t work for some reason. I am aware that -1 is just another way of indexing the last row, but directly putting the index of the last row should also work, shouldn’t it? apparently it didn’t in that excercise.