I'm new to Python and I'm working on a craps game. I got the basic code down, but I need to simulate a total of 200 games and track the number of wins. I need a counter in my program, but I can't figure out how to do this. Here's what I have so far:
import random
def roll():
die1 = random.randrange(1,7)
die2 = random.randrange(1,7)
print die1, ", ", die2
total = die1 + die2
return total
def main():
firstTry = roll()
print firstTry
if firstTry == 7 or firstTry == 11:
print "You win!"
elif firstTry == 2 or firstTry == 3 or firstTry == 12:
print "You lose."
else:
i = roll()
print i
while i != firstTry:
if i == 7:
print "You lose."
break
else:
i = roll()
if i == firstTry:
print "You win!"
main()