MCPcopy Index your code
hub / github.com/geekcomputers/Python / drawCards

Function drawCards

BoardGame-CLI/uno.py:58–70  ·  view source on GitHub ↗

Draw a number of cards from the top of the global `unoDeck`. Raises ValueError if the deck runs out of cards.

(numCards: int)

Source from the content-addressed store, hash-verified

56
57
58def drawCards(numCards: int) -> List[str]:
59 """
60 Draw a number of cards from the top of the global `unoDeck`.
61
62 Raises ValueError if the deck runs out of cards.
63 """
64 cardsDrawn: List[str] = []
65 for x in range(numCards):
66 try:
67 cardsDrawn.append(unoDeck.pop(0))
68 except IndexError:
69 raise ValueError("The deck is empty; cannot draw more cards")
70 return cardsDrawn
71
72
73"""

Callers 1

mainFunction · 0.85

Calls 2

appendMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected