Why Isn't a or b decreasing? I made the two variables global. What am I missing here?
from random import randint
from sys import *
global a
global b
a = 100
b = 100
if a or b != 0:
def userattack(b):
z = randint(10, 20)
print(("You strike for %s damage!") % int(z))
z - b
print(('The enemy\'s health Is now %s') % int(b))
def enemyattack(a):
x = randint(9, 19)
print(("The enemy strikes for %s damage") % int(x))
x - a
print(('Your health Is now %s') % int(b))
>>55713780
Use code tags
>>>/g/dpt
a -= x
b -= z
>>55714627
a -= x is short for a = a-x, just so you know
>>55713780
1) You're using global wrongdef func():
global a # this imports a from the global scope
global b # this imports b from the global scope
2) You're not assigning a or b new values
3) you're declaring a function within an if block, wtf is wrong with you?
4) you're passing b and a as arguments to the functions, overriding the symbol
5) you're not calling your functions anywhere