title: Difference between stock[item] -= 1 and stock[item] = stock[item] - 1?
body: <p>I've trying to write a small program that computes a bill based on certain lists. One of the requirements is to change to stock depending on what is taken out. I wrote my code the following way, and at least conceptually speaking, feel like I have the right idea.</p>
  
  <pre><code>shopping_list = ["banana", "orange", "apple"]
  
  stock = {
  "banana": 6,
  "apple": 0,
  "orange": 32,
  "pear": 15
  }
  
  prices = {
  "banana": 4,
  "apple": 2,
  "orange": 1.5,
  "pear": 3
  }
  
  def compute_bill(food):
      total = 0
      for item in food:
          if stock[item] &gt; 0:
              total += prices[item]
              stock[item] = stock[item] - 1
              return total
          else:
              return "Sorry: Out of Stock"
      return total
  </code></pre>
  
  <p>Unfortunately it doesn't work. I've looked up a potential solution and found one that goes like this.</p>
  
  <pre><code>groceries = ["banana", "orange","apple"]
  
  stock = {"banana": 6,
  "apple": 0,
  "orange": 32,
  "pear": 15
  }
  
  prices = {"banana": 4,
  "apple": 2,
  "orange": 1.5,
  "pear": 3
  }
  
  def computeBill(food):
      total = 0
      for item in food:  
          if stock[item] &gt; 0: 
              total += prices[item] 
              stock[item] -= 1
      return total
  
  print computeBill(groceries)
  </code></pre>
  
  <p>The main difference I see lies in these pieces of code:</p>
  
  <pre><code>stock[item] = stock[item] - 1
  
  stock[item] -= 1
  </code></pre>
  
  <p>What is the main difference between the two and why does the second one work? And what exactly does "-=" do? I could understand if it was a different method of getting the same thing to work, but that they're not equivalent leaves me confounded. Any input would be greatly appreciated and apologies in advance for my ignorance/stupidity.</p>