I am trying to Subtract player hp.
Here is my code example:
class player():
def __init__(self):
self.hp = 100
def check_death(self):
....
p = player()
p.hp - 10
print p.hp
But it is printing 100 so no Subtraction is done how can i fix it?
THX!
The expression
calculates a new value and then throws it away, because you haven’t told Python to put the result anywhere. Either do:
or Python supports the following shorthand for the above: