I'm not familiar with functions but somehow got the scenario 1 to work and print out a set of 5 random cards like so: A 3 J 2 8. In 2 however I'm trying to use the function poker_hand
in poker_game
so as to get something like:
Player 1: # # # # #,
Player 2: # # # # #,
etc.
But instead the output looks like:
5 6 10A 5 Player 2 <function poker_hand at 0x105818400>
K 7 A 2 6 Player 3 <function poker_hand at 0x105818400>
Q 104 3 3 Player 4 <function poker_hand at 0x105818400>
8 102 K 7 Player 5 <function poker_hand at 0x105818400>
5 2 A 6 2 Player 6 <function poker_hand at 0x105818400>
Q A 5 9 6 Player 7 <function poker_hand at 0x105818400>
A A 8 3 9 Player 8 <function poker_hand at 0x105818400>
K 8 3 J K Player 9 <function poker_hand at 0x105818400>
how could this be fixed?
cards = ['A ', '2 ', '3 ', '4 ', '5 ', '6 ', '7 ', '8 ', '9 ', '10', 'K
', 'Q ', 'J ']
def poker_hand(x):
for i in range(0, 5):
pick = random.choice(cards)
print(pick, end='')
return poker_hand
poker_hand(cards)
#
def poker_game(num_players):
for i in range(2, 10):
print("Player {}:".format(i), poker_hand(cards))
return poker_game
poker_game(cards)