title: defining and accessing a list of custom objects
body: <p>I have an object</p>
  
  <pre><code>class Car:
    def __init__(self):
      price = float(0)
  </code></pre>
  
  <p>Then another</p>
  
  <pre><code>class Day:
    def __init__(self):
      self.carList = [Car() for each in range(100)]
      self.createPriceList()
  
    def createPriceList(self):
      tempCar = Car()
      for i in range(100):
        tempCar.price = function_giving_a_value() # 10 last cars have 0.0 as value
        self.carList[i] = tempCar
        print i, self.carList[i].price 
  # prints the correct list : each line contains a correct price
  #edited after answers : in fact it's just misleading, cf answers
  
    def showPriceList(self):
      for i in range(len(self.carList)):
        print i, self.carList[i].price 
  # prints i (correct) but each self.carList[i].price as 0.0
  # so len(self.carList) gives correct value, 
  # but self.carList[i].price a wrong result
  </code></pre>
  
  <p>My question is :</p>
  
  <ul>
  <li>Why in <code>showPriceList()</code>, <code>self.carList</code> is correctly recognized (<code>len</code> gives the correct number in looping) but <code>self.carList[i].price</code> gives only zeros? (when it seems correctly filled in method <code>createPriceList()</code>)</li>
  </ul>