Dec-16-2016, 08:31 PM
You are trying to modify a global within a function. Consider this illegal (it is possible but highly discouraged so I'm not showing it).
Make attack take hp as an argument and return the new hp instead.
So your function could look like this:
Make attack take hp as an argument and return the new hp instead.
So your function could look like this:
def attack(hit_points): diceValue = random.randint(1, 10) return hit_points - diceValueAnd could be invoked like this:
hp = attack(hp)