The code below is part of a simple craps game that I am writing for practice. I have the dice rolling down, but I can't get this betting command to work out. The only module that I am really interrested here is the bet1(x) module but I copied the entire test code so that somebody could see exactly what I was trying to do.
Right now I'm just trying to make sure people can't enter invalid amounts to bet: no less than zero and no more than they have in the bank. A value in this range should end the loop and store the bet variable, but the loop doesn't break when I enter a number in the desired range. I've been tinkering with this for an embarrasingly long time now and I still can't get it to work.
This is my first post so I apologize if I'm missing anything or do this incorrectly.
def betting(): global bank; bank = 500 global bet; bet = 0 # defines the betting process within the program def bet1(x): #set bet loop bet_loop=0 #loop the bet process until the bet is valid while bet_loop == 0: #tell how much money you have print "You have", x, "dollars in the bank, how much do you bet?" #input b bet = raw_input("Wager?") #test to make sure that b and x stayed (i did this because it won't work.) print bet print x #checks to see if your bet is valid if bet == "quit": break elif bet <= 0 or bet > x: print "Invalid bet." else: break #runs the defined function with the value x set as the global value of bank bet1(bank) #another test to make sure its all working. print bank print bet