How to add an unspecified amount of variables together?
<p>I'm trying to add in python 3.5.2 but I have an unspecified amount of variables. I have to use very basic functions; I can't use <code>list</code>. I can't figure out how I'm supposed to add each new variable together without a <code>list</code>. When I run the code it adds the last entered <code>price1</code> which is <code>-1</code>. I need to use the <code>-1</code> to tell the program to total all the variables. </p>

<pre><code>count = 0

while (True):

     price1 = int( input("Enter the price of item, or enter -1 to get total: "))

     count += 1

     if (price1 ==-1):
         subtotal = (price1 + ) #this is where I"m having trouble
                                #at least I think this is the problem
         tax = (subtotal*0.05)
         total = (subtotal + tax)

         print("Subtotal: .  .  . . . ", subtotal)
         print("Tax: . .  . . . . . . ", tax)
         print("Total: . . . . . . . .", total)

         break
</code></pre>

<p>Keep another variable around and sum than up, also, <code>count</code> isn't used for anything so no real reason to keep it around. </p>

<p>For example, initialize a <code>price</code> name to <code>0</code>:</p>

<pre><code>price = 0
</code></pre>

<p>then, check if the value is <code>-1</code> and, if not, simply increment (<code>+=</code>) the <code>price</code> variable with the value obtained for <code>price1</code>:</p>

<pre><code>if price1 == -1:
    subtotal = price 
    tax =  subtotal*0.05
    total = subtotal + tax

    print("Subtotal: .  .  . . . ", subtotal)
    print("Tax: . .  . . . . . . ", tax)
    print("Total: . . . . . . . .", total)

    break
else:
    price += price1
</code></pre>

python python-2.7 python-3.x