Python elif not working in order I want
<p><code>Transaction_Code</code> == <code>"W"</code>, <code>"w"</code>, <code>"D"</code> or <code>"d"</code></p>

<p>if not, it should be running <code>Process_Invalid_Code(Previous_Balance)</code></p>

<p>What is happening, however is if input for <code>Transaction_Code</code> != <code>"W"</code>, <code>"w"</code>, <code>"D"</code> or <code>"d"</code>, it then continues to run the <code>"What is your previous balance?"</code> and <code>"How much is the transaction amount?"</code> input... </p>

<p>ONLY THEN, after you give input for those does it run <code>Invalid_Transaction_Code</code></p>

<p>What I WANT to happen is for it to throw <code>Invalid_Transaction_Code ("Invalid Transaction Code!")</code> etc. BEFORE without wasting the users time asking for Previous Balance and Transaction..</p>

<p>Does that make sense?</p>

<p>Here is the code</p>

<pre><code>#The main function definition

def main():
    Name = input("What is your name?  ")
    Account_ID = input("What is your account ID?  ")
    Transaction_Code = input("Press W or w for Withdrawal, Press D or d for Deposit:  ")
    Previous_Balance = float(input("What is your previous balance?  "))
    Transaction_Amount = float(input("How much is the transaction amount?  "))

    if Transaction_Code == "W" or Transaction_Code == "w":
        Withdrawal_Process(Previous_Balance, Transaction_Amount)
    elif Transaction_Code == "D" or Transaction_Code == "d":
        Deposit_Process(Previous_Balance, Transaction_Amount)
    else:
        Process_Invalid_Code(Previous_Balance)

#Defines the Deposit Process

def Deposit_Process(Previous_Balance, Transaction_Amount):
    New_Balance = Transaction_Amount + Previous_Balance
    Print_Function(New_Balance)


#Defines the Withdrawal Process

def Withdrawal_Process(Previous_Balance, Transaction_Amount):
    if Transaction_Amount &gt; Previous_Balance:
        print("Invalid Transaction: Not Sufficient Funds!")
        New_Balance = Previous_Balance
        Print_Function(New_Balance) 
    else:
        New_Balance = Previous_Balance - Transaction_Amount
        Print_Function(New_Balance)

#The Invalid Code Function Definition

def Process_Invalid_Code(Previous_Balance):
    New_Balance = Previous_Balance
    print ("Invalid Transaction Code!")
    print ("Please type W or w for Withdrawal")
    print ("or type D or d for Deposit")
    Print_Function(New_Balance)


#Defines the Print Function

def Print_Function(New_Balance):
    print ("Your balance is now $", format(New_Balance, '.2f'))  


#Call the main function

main()
</code></pre>

<p>Since all of your desired actions need <code>Previous_Balance</code> you must ask for it in any case:</p>

<pre><code>def main():
    # never used, lets ask anyway
    Name = input("What is your name?  ")

    # we need this information at a minimum
    Previous_Balance = float(input("What is your previous balance?  "))
    Transaction_Code = input("Press W or w for Withdrawal, Press D or d for Deposit:  ")

    # if its a withdrawal/deposit, find the amount and account
    if Transaction_Code.upper() in "WD":
        # we never use this Account_ID ...
        Account_ID = input("What is your account ID?  ")
        Transaction_Amount = float(input("How much is the transaction amount?  "))
        if Transaction_Code.upper() == "W":
            Withdrawal_Process(Previous_Balance, Transaction_Amount)
        else:
            Deposit_Process(Previous_Balance, Transaction_Amount)
    else:
        # they've entered a bad code
        Process_Invalid_Code(Previous_Balance)
</code></pre>

python