New to python and was my first try creating a loop, and after endless hours of trying to figure out what was wrong, I'm stumped. Here's the code:
if fightOptions == ' MELEE':
dummyHealth - damage
print ('Good job!')
if damage > dummyHealth:
time.sleep(2)
print ('You defeated the training dummy!')
gold = gold + 1
xp = xp + 2
if xp > 1:
print ('You levelled up!')
heroHealth + 5
damage = random.randint(4,22)
while dummyHealth > damage:
print ('You need to attack again!')
fightOptions = input ('MELEE, ITEM or SKILL?')
if fightOptions == ' MELEE':
dummyHealth - damage
if dummyHealth == 0:
break
time.sleep(2)
print ('You defeated the training dummy!')
gold = gold + 1
xp = xp + 2
the damage and dummyHealth are my own variables, damage being "damage = random.randint(2,20)" and dummyHealth being "dummyHealth = 100", whenever I run the code, it repeats the "print ('Good job!')" command and then the "print ('You need to attack again!')" "input ('MELEE, ITEM or SKILL?')" and then when anything is typed into the box, it just repeats the input command. Could you tell me what I've done wrong?
Thanks!
dummyHealth - damage
. You need a slightly different operator for that. – Jamal♦ Jan 12 at 19:20dummyHealth
, you need-=
. Read up on the different operators here. – Jamal♦ Jan 12 at 19:27