added deal_cards()

This commit is contained in:
Jonas_Jones 2022-12-22 15:37:48 +01:00
parent b5d23db85b
commit 80c794d8e6

28
game.py
View file

@ -14,5 +14,33 @@ def create_cards():
return card_deck return card_deck
def deal_cards(card_deck:list, players:int, cards_per_player:int):
'''
Deals cards to players
input:
- card_deck: list
list of cards
- players: int
number of players
- cards_per_player: int
number of cards per player
output:
- player_cards: tuple
tuple of lists, each list contains the cards of a player
'''
temp_cards = []
for player in range(players):
temp_cards.append([])
for card in range(cards_per_player):
temp_cards[player].append(card_deck.pop(0))
while len(temp_cards) < 5:
temp_cards.append([])
return (temp_cards[0], temp_cards[1], temp_cards[2], temp_cards[3], temp_cards[4])
card_deck = create_cards() card_deck = create_cards()
print(card_deck) print(card_deck)
print(deal_cards(card_deck, 5, 5))