Sales commission program using while loop. Value not updating
<p>My while loop isn't updating my new sales commission program eveerytime I run the program. Here is my program:</p>

<pre><code> #this program calculates sales commissions and sums the total of all sales commissions the user has entered

print("Welcom to the program sales commission loop")

keep_going='y'

while keep_going=='y':

    #get a salespersons sales and commission rate
    sales=float(input('Enter the amount of sales'))
    comm_rate=float(input('Enter commission rate'))

    total=0

    #calculate the commission
    commission=sales*comm_rate



    print("commission is",commission)



    keep_going=input('Enter y for yes')

    total=total+commission
    print("Total is",total)

print("You have exited the program. Thet total is",total)
</code></pre>

<p>Here is the output of the program: Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25          2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
    Type "copyright", "credits" or "license()" for more information.</p>

<blockquote>
  <blockquote>
    <blockquote>
      <p></p>
    </blockquote>
  </blockquote>
</blockquote>

<pre><code>Welcom to the program sales commission loop
Enter the amount of sales899
Enter commission rate.09
commission is 80.91
Enter y for yesy
Total is 80.91
Enter the amount of sales933
Enter commission rate.04
commission is 37.32
Enter y for yesy
Total is 37.32
Enter the amount of sales9909
Enter commission rate.10
commission is 990.9000000000001
Enter y for yesn
Total is 990.9000000000001
You have exited the program. Thet total is 990.9000000000001
&gt;&gt;&gt; 

&gt; Blockquote
</code></pre>

<p>What am I doing wrong? I cannot figure it out </p>

<p>Every time you loop you are setting total to zero. Move your initialization of total to outside of the loop as I show below.</p>

<pre><code>#this program calculates sales commissions and sums the total of all sales commissions the user has entered

print("Welcom to the program sales commission loop")

keep_going='y'

total=0
while keep_going=='y':

    #get a salespersons sales and commission rate
    sales=float(input('Enter the amount of sales'))
    comm_rate=float(input('Enter commission rate'))

    #calculate the commission
    commission=sales*comm_rate

    print("commission is",commission)

    keep_going=input('Enter y for yes')

    total=total+commission
    print("Total is",total)

print("You have exited the program. Thet total is",total)
</code></pre>

python while-loop updating