<corylog...@yahoo.com.dmarc.invalid> Wrote in message: > > > > > <!-- > p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph { > margin-top:0in; > margin-right:0in; > margin-bottom:0in; > margin-left:.5in; > margin-bottom:.0001pt; > } > p.MsoNormal, li.MsoNormal, div.MsoNormal { > margin:0in; > margin-bottom:.0001pt; > } > p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, > div.MsoListParagraphCxSpFirst, > p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, > div.MsoListParagraphCxSpMiddle, > p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, > div.MsoListParagraphCxSpLast { > margin-top:0in; > margin-right:0in; > margin-bottom:0in; > margin-left:.5in; > margin-bottom:.0001pt; > line-height:115%; > } > --> > > Hello, I can not for the life of me figure out where I have gone wrong. I > wrote the following code as a simulation for the table top game x-wing. It > basically simulates dice rolls but the issue is the fact that every time I > choose a number of dice to roll, they all hit. None of them ever miss. > Thank You. > import random > print("X-wing dice simulator") > x = int(input("How many dice will the offensive player be rolling?\n")) > y = int(input("How many dice will the defensive player be rolling?\n")) > hits = 0 > crits = 0 > dodges = 0 > offense = 0 > defense = 0 > while offense < x: > odie = random.randint(1,8) > if odie <= 4: > hits = hits + 1 > offense = offense + 1
> if odie == 4: This should be indented, to line up with offens= line > crits = crits + 1 > offense = offense + 1 > else: Then this else will mean odie >4 But then instead of continue, you'll need to increment offense. > continue > while defense < y: > ddie = random.randint(1,8) > if ddie <= 3: > dodges = dodges + 1 > defense = defense + 1 > else: > continue Continue doesn't help, you need to increment defense. > print("The offensive player lands", hits,"hits and", crits,"crits\n") > print("The defensive player dodges", dodges, "hits\n") > print("The offensive player deals", int((hits + crits) - dodges), "to the > defensive player") > > You'd have done yourself a favor to do loops with range (), instead of the while loops. For example for qq in range (x): -- DaveA _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor