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

Function displayCards

src/gamesbyexample/blackjack.py:195–215  ·  view source on GitHub ↗

Display all the cards in the cards list.

(cards)

Source from the content-addressed store, hash-verified

193
194
195def displayCards(cards):
196 """Display all the cards in the cards list."""
197 rows = ['', '', '', '', ''] # The text to display on each row.
198
199 for i, card in enumerate(cards):
200 rows[0] += ' ___ ' # Print the top line of the card.
201 if card == BACKSIDE:
202 # Print a card's back:
203 rows[1] += '|## | '
204 rows[2] += '|###| '
205 rows[3] += '|_##| '
206 else:
207 # Print the card's front:
208 rank, suit = card # The card is a tuple data structure.
209 rows[1] += '|{} | '.format(rank.ljust(2))
210 rows[2] += '| {} | '.format(suit)
211 rows[3] += '|_{}| '.format(rank.rjust(2, '_'))
212
213 # Print each row on the screen:
214 for row in rows:
215 print(row)
216
217
218def getMove(playerHand, money):

Callers 1

displayHandsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected