title: TypeError: 'Food' object does not support indexing
body: <pre><code>self.food_list = [['apple', 100, 'Fruit', 384.0], ['orange', 100, 'Fruit', 384.0]]
  </code></pre>
  
  <p>I want to sum the element from the index 3. 
  Expected output is <code>Total calorie of all food is 768.0Kcal</code></p>
  
  <pre><code>def totalCalorie(self):
      for i in range(0, len(self.food_list)):
          j = self.food_list[i][3]
          j += j
      print("Total calorie of all food is {}Kcal".format(j))
  </code></pre>
  
  <p>But the following error came out:</p>
  
  <pre><code>Traceback (most recent call last):
    File "D:/PythonTim/Assignment/nutritionDriver.py", line 60, in &lt;module&gt; 
      main()
    File "D:/PythonTim/Assignment/nutritionDriver.py", line 43, in main
      patient.totalCalorie()
    File "D:\PythonTim\Assignment\nutritionApp.py", line 132, in totalCalorie
      j = self.food_list[i][3]
  TypeError: 'Food' object does not support indexing
  </code></pre>
  
  <p>The thing I want to do is when the user wants to total up all the calories that in the list, the system will display the total calories from the list.</p>
  
  <p>Is there another way to do it? Thanks!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>class Food:
      def __init__(self, name, quantity, category, calorie):
          self.name = name
          self.quantity = quantity
          self.category = category
          self.calorie = calorie
  
  class FoodList:
  
      def __init__(self):
          self.food_list = []
  
      def totalCalorie(self):
          j=0
          for i in self.food_list:
              j += i[3]
          print("Total calorie of all food is {}Kcal".format(j))
  
      def addFood(self, newfruit):
          self.food_list.append(newfruit)
  
  name = input("Name? ")
  quantity = input("Quantity? ")
  category = input("Category? ")
  calorie = input("Calorie? ")
  f = Food(name, quantity, category, calorie)
  patient = FoodList()
  patient.addFood(f)
  
  name1 = input("Name? ")
  quantity1 = input("Quantity? ")
  category1 = input("Category? ")
  calorie1 = input("Calorie? ")
  f1 = Food(name1, quantity1, category1, calorie1)
  patient.addFood(f1)
  
  patient.totalCalorie()
  </code></pre>