Can't kick out of while loop
<pre><code>#Fiery Elsa
#ID:899525
#Homework 2, Program 2


#Initialization
count=0
name=input("Enter stock name OR -999 to Quit:")

#Input
while name!=-999:
    count=count+1
    name=input("Enter stock name OR -999 to Quit:")
    shares=int(input("Enter number of shares:"))
    pp=float(input("Enter purchase price:"))
    sp=float(input("Enter selling price:"))
    commission=float(input("Enter commission:"))


#Calculations
amount_paid=shares*pp
commission_paid_purchase=amount_paid*commission
amount_sold=shares*sp
commission_paid_sale=amount_sold*commission
profit_loss=(amount_sold - commission_paid_sale) -(amount_paid + commission_paid_purchase)

#Output
print("Stock Name:", name)
print("Amount paid for the stock:       $", format(amount_paid, '10,.2f'))
print("Commission paid on the purchase: $", format(commission_paid_purchase, '10,.2f'))
print("Amount the stock sold for:       $", format(amount_sold, '10,.2f'))
print("Commission paid on the sale:     $", format(commission_paid_sale, '10,.2f'))
print("Profit (or loss if negative):    $", format(profit_loss, '10,.2f'))
</code></pre>

<p>Program loops, but doesn't kick out to print output when you press -999. What am I doing wrong?</p>

<p>Ideally, the program should allow the user to input as many times as he/she wants until the user is done. For example: 3 sets of inputs resulting in 3 sets of outputs. </p>

<p>Your problem seems to be that <code>name</code> is type <code>string</code>, but you're comparing it to <code>-999</code> which has type <code>int</code>.</p>

<p>If you change your loop to read <code>name != "-999"</code> then the comparison works.  You'll need to refactor your code some more to make it behave the way you're wanting, but this should be a good start :)</p>

python python-3.x while-loop