I was wondering how can I change sys.exit so if you use command line to run the program. it prompts a message asking if the user wants to exit instead of automatically just exiting?<div><br></div><div>import random</div><div>
import sys</div><div><div>my_hp = 50</div><div> mo_hp = 50</div><div> menu1 = """</div><div> Menu Selections: </div><div> 1 - Attack</div><div> 2 - Defend</div><div> 3 - Help</div>
<div> 4 - Exit</div><div> """</div><div> print menu1</div><div> while True:</div><div> my_dmg = random.randrange(1, 20)</div><div> mo_dmg = random.randrange(1, 20)</div><div>
<br></div><div> choice = input ("\nEnter your selection. ")</div><div> choice = float(choice)</div><div> print</div><div> if choice == 1:</div><div> mo_hp = mo_hp - my_dmg</div>
<div> if mo_hp <= 0:</div><div> print "Iris is at 0 Hit Points!\nYOU HAVE SLAIN IRIS!"</div><div> sys.exit(0)</div><div> elif mo_hp > 0:</div><div> print "-----------------------------------------------------------------"</div>
<div> print "Iris is at %s Hit Points\nYou did %s damage\n" % (mo_hp, my_dmg)</div><div> my_hp = my_hp - mo_dmg</div><div> if my_hp <= 0:</div><div> print "Your Hit Points are 0!\nYOU HAVE BEEN SLAIN BY Iris!"</div>
<div> sys.exit(0)</div><div> elif my_hp > 0:</div><div> print name,"was attacked by Iris for %s damage!\nMy Hit Points are %s" % (mo_dmg, my_hp)</div><div> print "-----------------------------------------------------------------"</div>
<div> else:</div><div> print menu1</div><div> </div><div> </div><div> elif choice == 2:</div><div> mo_hp = mo_hp - my_dmg / 2</div><div> if mo_hp <= 0:</div>
<div> print "The Lich King is at 0 Hit Points!\nYOU HAVE SLAIN IRIS!"</div><div> sys.exit(0)</div><div> elif mo_hp > 0:</div><div> print "-----------------------------------------------------------------"</div>
<div> print "The Lich King is at %s Hit Points\nYou did %s damage\n" % (mo_hp, my_dmg)</div><div> my_hp = my_hp - mo_dmg / 2</div><div> if my_hp <= 0:</div><div> print "Your Hit Points are 0!\nYOU HAVE BEEN SLAIN BY IRIS!"</div>
<div> sys.exit(0)</div><div> elif my_hp > 0:</div><div> print name,"was attacked by the Iris for %s damage!\nMy Hit Points are %s" % (mo_dmg, my_hp)</div><div> print "-----------------------------------------------------------------"</div>
<div> else:</div><div> print menu1</div><div> </div><div> elif choice == 3:</div><div> print """</div><div> -------------------------------------------------------------</div>
<div> Attack = Attack for 100% of damage.</div><div> Defending = Attack for 50% of damage and endure 50% of damage.</div><div> -------------------------------------------------------------</div>
<div> """</div><div> elif choice == 4:</div><div> sys.exit(0)</div></div>