Question

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'

Was it helpful?

Solution

false should be spelled False (capital F).

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

OTHER TIPS

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.

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")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top