<div>I am have trouble figuring out how to make my program stop at 0 hit points.... if I run it, it always goes into the negative hitpoints... </div>
<div> </div>
<div>So my question is how do I make this program end at exactly 0 hit points every time instead of going over?</div>
<div> </div>
<div>and also, what can I do instead of writing print so many times?</div>
<div> </div>
<div>import random</div>
<div> my_hp = 50<br> mo_hp = 50<br> my_dmg = random.randrange(1, 20)<br> mo_dmg = random.randrange(1, 20)<br> while True:<br> if mo_hp < 0:<br> print "The Lich King has been slain!"<br>
elif my_hp < 0:<br> print "You have been slain by the Lich King!"<br> if mo_hp <= 0:<br> break<br> elif my_hp <= 0:<br> break<br> else:<br> print "Menu Selections: "<br>
print "1 - Attack"<br> print "2 - Defend"<br> print<br> choice = input ("Enter your selection. ")<br> choice = float(choice)<br> print<br>
if choice == 1:<br> mo_hp = mo_hp - my_dmg<br> print "The Lich King is at ", mo_hp, "Hit Points"<br> print "You did ", my_dmg, "damage!"<br>
print<br> my_hp = my_hp - mo_dmg<br> print "I was attacked by the lk for ", mo_dmg," damage!"<br> print "My Hit Points are ", my_hp<br> print<br>
elif choice == 2:<br> mo_hp = mo_hp - my_dmg / 2<br> print "The Lich King is at", mo_hp, "Hit Points"<br> print "you did ", my_dmg / 2, "damage!"<br>
print<br> my_hp = my_hp - mo_dmg<br> print "I was attacked by the lk for ", mo_dmg," damage!"<br> print "My Hit Points are ", my_hp<br> print</div>
<div> </div>