MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / getBet

Function getBet

src/gamesbyexample/blackjack.py:123–137  ·  view source on GitHub ↗

Ask the player how much they want to bet for this round.

(maxBet)

Source from the content-addressed store, hash-verified

121
122
123def 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
140def getDeck():

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected