title: How to make cash register total by allowing the user to insert the amount of cash into the list and the list is in the string?
body: <p>I want to make cash register total by allowing the user insert the amount of cash into the list. But It give me this error:</p>
  
  <pre><code>Purchase :12
  Purchase :23
  Purchase :12
  Purchase :29.2
  Purchase :11
  Purchase :q
  ['12', '23', '12', '29.2', '11']
  11.0
  ['12', '23', '12']
  12.0
  ['12']
  12.0
  Traceback (most recent call last):
    File "C:\Users\Wan Afifi\Desktop\Python\append.py", line 17, in &lt;module&gt;
      add = float(purchase_amount.pop())
  IndexError: pop from empty list
  </code></pre>
  
  <p>Here I attach my code. I wonder to know what the problem with my code? But here I have to do <code>.pop()</code> to complete the task.</p>
  
  <pre class="lang-python prettyprint-override"><code>purchase_amount = []
  x = 0
  
  while True:
      purchase_amount1 = input("Purchase :")
      if purchase_amount1.upper() != "Q":
          purchase_amount.insert(x, purchase_amount1)
          x = x + 1
      else:
          break
  
  print(purchase_amount)
  subtotal = 0
  while len(purchase_amount) != 0:
      print(float(purchase_amount.pop()))
      add = float(purchase_amount.pop())
      print(purchase_amount)
      subtotal = add + add
  
  print(subtotal)
  </code></pre>