I am new to coding, and I am trying to understand why I am getting this error. It's some sort of spacing error, and I've been working on this for quite a while now. Any insight would be appreciated. I've also inserted my error on codio.
Actual Output:
What would you like to do?
How much would you like to withdraw today? Withdraw amount was $100.00, your current balance is $400.25
Thank you for banking with us.
Expected Output:
What would you like to do?
How much would you like to withdraw today?
Withdrawal amount was $100.00, current balance is $400.25
Actual Output:
What would you like to do?
How much would you like to withdraw today? $700.00 is greater that your account balance of $500.25
Thank you for banking with us.
Expected Output:
What would you like to do?
How much would you like to withdraw today?
$700.00 is greater than your account balance of $500.25
import sys
#account balance
account_balance = float(500.25)
#<--------functions go here-------------------->
#printbalance function
def balance():
print("Your current balance: $%.2f" % account_balance)
#deposit function
def deposit():
deposit_amount = float(input("How much would you like to deposit? "))
balance = account_balance - deposit_amount
print("Deposit amount was $%.2f, current balance is $%.2f" % (deposit_amount, balance))
#withdraw function
def withdraw():
withdraw_amount = float(input("How much would you like to withdraw today? "))
if withdraw_amount > account_balance:
print("$%.2f is greater that your account balance of $%.2f" % (withdraw_amount, account_balance))
else:
balance = account_balance - withdraw_amount
print("Withdraw amount was $%.2f, your current balance is $%.2f" % (withdraw_amount, balance))
#User Input goes here, use if/else conditional statement to call function based on user input
userchoice = input ("What would you like to do?\n")
if (userchoice == "D"):
deposit()
elif (userchoice == "B"):
balance()
elif (userchoice == "W"):
withdraw()
print("Thank you for banking with us.")
account balance
account_balance = float(500.25)
<--------functions go here-------------------->
printbalance function
deposit function
withdraw function
User Input goes here, use if/else conditional statement to call function based on user input
For the first couple of checks, make sure to put a # sign in the print("Thank you for banking with us.") area, as it is not supposed to be written.
This is the final revision for this code.