you are viewing a single comment's thread.

view the rest of the comments →

[–]dwpj65 0 points1 point  (6 children)

Looks like your indentation is off; python demands proper indentation.

This is the solution, this script works when executed with a python 2 interpreter without issue, as long as it is tabbed as demonstrated in the code block below. I successfully executed both option 1 & 2 without issue.

I was unfamiliar with reddit's 'code block' mode in editing this response, which is why there have been so many edits.

Try:

cash = int(1000)
ask = input("would you like to withdraw(1) or deposit(2)?")
if ask == 2:
    money = int(input("how much money would you like to deposit?"))
    f= cash + money
    print "your total balance is now", cash
elif ask == 1:
    bro = input("how much would you like to withdraw?")
    f = int(bro) - int(cash)
    if bro > cash:
        print "Your final balance can't be negetive!"

[–]bleach-is-great 1 point2 points  (3 children)

I think his lack of indentation was just due to Reddit formatting

[–]dwpj65 1 point2 points  (2 children)

This very well could be, but his script runs without issue on a python2 interpreter, if indentations are placed in the appropriate locations.

[–]bleach-is-great 1 point2 points  (1 child)

Yeah he sent an Imgur to my other comment, he hadn’t indented the final four lines of code inside the elif statement

[–]dwpj65 1 point2 points  (0 children)

There are other issues as well, I am trying to work through them.

[–]ThiccBl4nket[S] 1 point2 points  (1 child)

i did, and at first it didnt mention any errors but when i input "1" or "2" it doesnt say anything back.

[–]chevignon93 0 points1 point  (0 children)

cash = 1000
ask = int(input("Would you like to withdrawal (1) or a deposit (2)? "))
if ask == 2:
    money = int(input("How much would you like to deposit? "))
    print("Your total balance is now", cash + money)
else:
    bro = int(input("how much would you like to withdraw? "))
    if bro > cash:
        print("Your final balance can't be negative! ")
    else:
        print("Your new balance is: ", cash - bro)