title: I am trying to add to a dictionary in python using .update()
body: <p>I create a dictionary, ss, which has a total number of shares for a specific stock.  Then I need to do some calculations and create a new dictionary, temp, which I will feed into my .html page for presentation.  The update function does not work as I intend because all that is in temp is the last stock, not a listing of all the stocks I have purchased. When I print ss, there is [{key:value, etc}], but when I print temp there is no [  ] around the {key:value, etc}.  I think I am missing something basic.</p>
  <p>Also my .html page is not reading the temp dictionary as the page is empty. Here is the code:</p>
  <pre><code>@app.route(&quot;/&quot;)
  @login_required
  def index():
      &quot;&quot;&quot;Show portfolio of stocks&quot;&quot;&quot;
      #dictionary to feed data into index
      temp={}
      #Select from trades all stocks held by this user
      ss = db.execute(&quot;SELECT SUM(shares), symbol FROM trades WHERE id=? GROUP BY symbol&quot;, session[&quot;user_id&quot;])
      print(ss)
      #lookup current price for each stock and create index of all stocks held
      for row in ss:
          data=lookup(row[&quot;symbol&quot;])
          totval=row[&quot;SUM(shares)&quot;]*data[&quot;price&quot;]
          temp1={&quot;symbol&quot;:data[&quot;symbol&quot;], &quot;name&quot;:data[&quot;name&quot;], &quot;shares&quot;:row[&quot;SUM(shares)&quot;], &quot;price&quot;:data[&quot;price&quot;], &quot;total value&quot;:totval}
          temp.update(temp1)
          
      print(temp)
      return render_template(&quot;index.html&quot;, temp=temp)
  </code></pre>
  <p>Any direction would be great.  Thanks.</p>