Ask the player how much they want to bet for this round.
(maxBet)
| 121 | |
| 122 | |
| 123 | def getBet(maxBet): |
| 124 | """Ask the player how much they want to bet for this round.""" |
| 125 | while True: # Keep asking until they enter a valid amount. |
| 126 | print('How much do you bet? (1-{}, or QUIT)'.format(maxBet)) |
| 127 | bet = input('> ').upper().strip() |
| 128 | if bet == 'QUIT': |
| 129 | print('Thanks for playing!') |
| 130 | sys.exit() |
| 131 | |
| 132 | if not bet.isdecimal(): |
| 133 | continue # If the player didn't enter a number, ask again. |
| 134 | |
| 135 | bet = int(bet) |
| 136 | if 1 <= bet <= maxBet: |
| 137 | return bet # Player entered a valid bet. |
| 138 | |
| 139 | |
| 140 | def getDeck(): |