Unwanted looping occurring on first function
<pre><code>def load():    
    name=0
    count=0
    totalpr=0
    name=input("Enter stock name OR -999 to Quit: ")
    while name != '-999':
        count=count+1
        shares=int(input("Enter number of shares: "))
        pp=float(input("Enter purchase price: "))
        sp=float(input("Enter selling price: "))
        commission=float(input("Enter commission: "))
        name=input("Enter stock name OR -999 to Quit: ")

def calc():
    totalpr=0
    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)
    totalpr=totalpr+profit_loss

def display():
    print("\nStock 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'))
    print("Total Profit is $", format(totalpr, '10,.2f'))

def main():
    load()
    calc()
    display()

main()
</code></pre>

<p>Immediately after commission is entered, the program should run the calculations and display the information accordingly. But right now, it's simply looping and not displaying/calculating anything. </p>

<p>I would like to maintain the structure of program itself --</p>

<pre><code>def main():
load()
calc()
display()
</code></pre>

<p>But there is something else impeding the program from carrying the results of load into calc and then into display in that order. </p>

<p>My inexperienced (this is for a class) thought? It might be something with kicking out of the while loop after the stock information is loaded. There isn't (in my opinion) anything telling the program to move onto calc() and then move onto display()...I thought it was being achieved with the def main(): sequence but I could be wrong. </p>

<p>This is what the output should look like: </p>

<pre><code>============== RESTART: C:\Users\ELSSAAAAA\Desktop\Sample.py ==============
Enter stock name OR -999 to Quit: GOOGLE
Enter number of shares: 10000
Enter purchase price: 30
Enter selling price: 300
Enter commission: 0.04

Stock Name: GOOGLE
Amount paid for the stock:       $ 300,000.00
Commission paid on the purchase: $  12,000.00
Amount the stock sold for:       $ 3,000,000.00
Commission paid on the sale:     $ 120,000.00
Profit (or loss if negative):    $ 2,568,000.00

Enter stock name OR -999 to Quit: AMAZON
Enter number of shares: 10000
Enter purchase price: 25
Enter selling price: 250
Enter commission: 0.04

Stock Name: AMAZON
Amount paid for the stock:       $ 250,000.00
Commission paid on the purchase: $  10,000.00
Amount the stock sold for:       $ 2,500,000.00
Commission paid on the sale:     $ 100,000.00
Profit (or loss if negative):    $ 2,140,000.00

Enter stock name OR -999 to Quit: -999
Total Profit is $ 14,260,000.00
</code></pre>

<p>First you have to define all variables globally or pass it as a parameter,
and then you have to call your function inside your while loop.For simplicity I am defining it as a global variable.</p>

<pre><code>shares = 0
pp = 0
sp = 0
commission = 0
name = ""
amount_paid = 0
profit_loss = 0
totalpr = 0
commission_paid_purchase = 0
commission_paid_sale = 0
amount_sold = 0

def load():    
    name=0
    count=0
    totalpr=0
    name=input("Enter stock name OR -999 to Quit: ")
    while name != '-999':
        count=count+1
        shares=int(input("Enter number of shares: "))
        pp=float(input("Enter purchase price: "))
        sp=float(input("Enter selling price: "))
        commission=float(input("Enter commission: "))
        calc()
        display()
        name=input("Enter stock name OR -999 to Quit: ")

def calc():
    totalpr=0
    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)
    totalpr=totalpr+profit_loss

def display():
    print("\nStock 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'))
    print("Total Profit is $", format(totalpr, '10,.2f'))

def main():
    load()
    calc()
    display()

main()
</code></pre>

python function python-3.x while-loop