Reputation: 55
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'
Upvotes: 0
Views: 163
Reputation: 1123032
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")
Upvotes: 0
Reputation: 122416
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
.
Upvotes: 1
Reputation: 500585
false
should be spelled False
(capital F
).
The intent behind currentbank-minusbank=afterbank
is unclear to me, but it is not valid code.
Upvotes: 2