I get an eternal loop on this game that I don't want and can't figure out how to fix.
BTW any of you know the rules to craps? I don't remember them all so this game may be different than the casino version.


Here's my code:

import random

# generate random numbers 1 - 6

loop = True
def play_again():
    play_again = raw_input("Play again? (Y/N)\n>> ")
    if play_again == ("Y") or ("y") or ("Yes") or ("yes") or ("YES"):
        crapps()
    else:
        loop = False
        print "\nCome play again."

def roll():
    raw_input("\nPress the 'Enter' key (Return) to roll.")

def crapps():
    while loop:
        die1 = random.randrange(6) + 1
        die2 = random.randrange(6) + 1
        die1_2 = random.randrange(6) + 1
        die2_2 = random.randrange(6) + 1

        total_cash = 100

        title_ = "The fun game of craps."
        print title_.title()

        print "You have %d dollars on hand." % total_cash
        print "Now you will wager 10 dollars for the game."
        total = die1 + die2
        total_2 = die1_2 + die2_2

roll()
print "\nYou rolled a", die1, "and a", die2, "for a total of", total
raw_input("\nPress the 'Enter' key (Return) to let your opponent roll")
print "\nYour opponent rolled a", die1_2, "and a", die2_2, "for a total of", total_2


        if total > total_2:
            total_cash = total_cash + 10
            print "\nYou won! You now have %d dollars on hand." % total_cash
            play_again()


else: total_cash = total_cash - 10 print "You lost. Too bad. Better luck next time." if total_cash < 0: print "Get out of this casino and work! You're in debt!" elif total_cash == 0: print "Better stop now before you get into debt."

            play_again()

crapps()

I also can't get the counter to save the added or removed money. every time I play again, I always have $100

Thanks,
   Joe

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to