Lists and for loops 2.indexing

Hi people…still new to python…i am adding the fourth elements from the lists but as i convert the float to int i get different sums.
and when i hit the submit button there is an error.

below i have provided one of my codes

my first 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 = int(row_1[4])
ratings_2 = int(row_2[4])
ratings_3 = int(row_3[4])
total = ratings_1 + ratings_2 + ratings_3
average = total / 3
print (total)
print (int (average))

out put

Output

11 3

ERROR

  • average is less than what we expected.
  • ratings_1 is less than what we expected.
  • ratings_2 is less than what we expected.
  • ratings_3 is less than what we expected.
  • total is less than what we expected

Hi @pontshotshipe, welcome to the community!

This should help you out: the indexing always starts at 0, so row_1[0] would be the 1st element, row_1[1] would be the 2nd element, and so on. It takes a bit to get used to!