0

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

Codio Error

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.")
Solomon Ucko
  • 5,724
  • 3
  • 24
  • 45
Ryan Miller
  • 19
  • 1
  • 5
  • Please copy the code into the question. The picture is blurry, making it hard to read the code, and it is impossible to copy-paste it to reproduce the problem. Blind users will also be unable to view the code. You should also be able to copy-paste the error message. If not, include a screenshot (not a link to a screenshot) of the error message into the post. – Solomon Ucko Dec 02 '18 at 22:16
  • Code reposted with a better attachment of codio error, thanks – Ryan Miller Dec 02 '18 at 23:03
  • It also would be helpful if you could copy/paste the input and the expected and actual output. BTW, why do you mind having an image instead of a link to one? – Solomon Ucko Dec 02 '18 at 23:05
  • I cannot save the webpage as an image file. I would like for all scrolling features to be in the image, but I can't seem to figure it out – Ryan Miller Dec 02 '18 at 23:43
  • Can you copy the text? I can help you format it if necessary. – Solomon Ucko Dec 02 '18 at 23:46
  • Text copied into original message – Ryan Miller Dec 03 '18 at 00:05
  • See [mcve] guidelines in the Help Center -- a good question has *only the smallest possible amount of code* that serves to illustrate a specific problem. That is, a problem with the code, not a larger (homework/program-goal) thing you're trying to solve. Similarly, the title should be focused on a *specific technical problem*, so that other people encountering that same problem can find your question (and its answers) rather than needing to ask the same thing again. – Charles Duffy Dec 03 '18 at 00:26

2 Answers2

1
enter code hereimport 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 today?\n"))
     balance = account_balance + deposit_amount
     print("Deposit 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?\n"))
    if withdraw_amount > account_balance:
    print("$%.2f is greater than your account balance of $%.2f" % (withdraw_amount, 
    account_balance))
else:
    balance = account_balance - withdraw_amount
    print("Withdrawal amount was $%.2f, 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.")

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.

Ryan Miller
  • 19
  • 1
  • 5
0

I think part of the problem is that the "Thank you for banking with us." message is not supposed to be output. Also, it seems that the tests require you to print a line break after taking input (which would normally be input by the user).

Solomon Ucko
  • 5,724
  • 3
  • 24
  • 45
  • This was a very good point. A lot of these Codio exercises are broken up into sections. It get very cryptic in terms of when to add the # sign. It may be part of a necessary code, and even necessary for the final string. It's bizarre that it reads it this way because you may have to remove a readable code that may be necessary on another exercise. – Ryan Miller Dec 03 '18 at 02:34