0

It says that it can't assign the operator. Why doesn't this work?

print ("Welkom")
print ("Voer het huidige bedrag op uw rekening in")
currentbank = input ("huidige bedrag:€")
print ("Hoeveel wil je erafhalen")
minusbank = input ("min:€")
print ("Je hebt als je dit doet:")
afterbank = false 
afterbank = currentbank - minusbank
print ("Dankjewel dat je dit programma gebruikt hebt")

"afterbank = currentbank - minusbank" has this error:

TypeError: unsupported operand type(s) for -: 'str' and 'str'

2
  • 1
    Please do include the full traceback when you have a problem. Commented Nov 13, 2013 at 13:22
  • 1
    currentbank-minusbank=afterbank What are you trying to do here? My guess is you wanted to do afterbank=currentbank-minusbank, and then afterbank=False is not needed at all. But I may be wrong. Commented Nov 13, 2013 at 13:25

3 Answers 3

2

false should be spelled False (capital F).

The intent behind currentbank-minusbank=afterbank is unclear to me, but it is not valid code.

Sign up to request clarification or add additional context in comments.

Comments

1

Two things:

afterbank=false 

You should spell it as False. In Python True and False are spelled with capitals.

The following line also won't work (it's incorrect):

currentbank-minusbank=afterbank

I think you meant:

afterbank = currentbank - minusbank

which means you subtract minusbank from currentbank and you store the result in afterbank.

Comments

0

You are trying to use assignment on an expression:

currentbank-minusbank=afterbank

This doesn't work; there is no name to assign to here. Perhaps you wanted to test for equality here?

currentbank - minusbank == afterbank

Now you have a valid expression, but the result (True or False) is ignored.

Your editor is also showing that you are using a name you didn't define; false is seen as a name, not the value False, so it is warning you that a NameError will likely be raised there.

I think you wanted to show the result of the sum:

afterbank = currentbank - minusbank
print("Nu heb je", afterbank, "over")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.