title: Map method in python
body: <pre><code>class FoodExpert:
      def init(self):
          self.goodFood = []
      def addGoodFood(self, food):
          self.goodFood.append(food)
      def likes(self, x):
          return x in self.goodFood
      def prefers(self, x, y):
          x_rating = self.goodFood.index(x)
          y_rating = self.goodFood.index(y)
          if x_rating &gt; y_rating:
              return y
          else:
              return x
  </code></pre>
  
  <p>After declaring this class , I wrote this code :</p>
  
  <pre><code>&gt;&gt;&gt; f = FoodExpert()
  &gt;&gt;&gt; f.init()
  &gt;&gt;&gt; map(f.addGoodFood, ['SPAM', 'Eggs', 'Bacon', 'Rat', 'Spring Surprise'])
  [None, None, None, None, None]
  
  &gt;&gt;&gt; f.goodFood
  ['SPAM', 'Eggs', 'Bacon', 'Rat', 'Spring Surprise']
  </code></pre>
  
  <p>I am unable to understand how the map function is working behind the hood , why is it returning a list with all <code>None</code> , but when I check <code>f.goodFood</code> the elements have been added there ? </p>