Im trying to shuffle the cards, and from the shuffled deck print out 2 hands like in poker (so 10 cards total). but rather than connecting it to the original code itself i made a seperate block that'll shuffle and get the 2 hands and dont know how to connect it to the original code.
need to shuffle whats below and get two hands of the cards
dCardNames = ['2','3','4','5','6','7','8','9','10','J','Q','K','A']
dCardValues = ['2','3','4','5','6','7','8','9','10','11','12','13','14']
dSuits = ["Clubs","Spades","Diamonds","Hearts"]
# Build a two dimensional deck with Cards suits and values.
aCards = [['' for i in range(52)] for j in range(3)]
i = 0
n = 0
while i < 13:
aCards[0][i] = dCardNames[i]
aCards[0][i + 13] = dCardNames[i]
aCards[0][i + 26] = dCardNames[i]
aCards[0][i + 39] = dCardNames[i]
aCards[1][i] = dSuits[0]
aCards[1][i + 13] = dSuits[1]
aCards[1][i + 26] = dSuits[2]
aCards[1][i + 39] = dSuits[3]
aCards[2][i] = dCardValues[i]
aCards[2][i + 13] = dCardValues[i]
aCards[2][i + 26] = dCardValues[i]
aCards[2][i + 39] = dCardValues[i]
i = i + 1
i = 0
while i < 52:
print (aCards[0][i], " ", aCards[1][i], " ", aCards[2][i])
i = i + 1
^thats the original code
import random
hands = {}
card_values = {1:"1", 2:"2", 3: "3", 4: "4", 5: "5", 6: "6", 7: "7", 8: "8", 9: "9", 10: "10", 11: "J", 12: "Q", 13: "K", 14: "A"}
card_types = {1: "Spades", 2: "Hearts", 3: "Diamonds", 4: "Clubs"}
deck = []
for i_type in range(1,5):
for i_value in range(1, 15):
deck.append(card_types[i_type] + " " + card_values[i_value])
# Could be handled as inputs
#hands_amt = int(input("How many players?: "))
#cards_per_hand = int(input("How many cards per player?: "))
#or set value
hands_amt = 2
cards_per_hand = 5
for i_hands in range(1, hands_amt+1):
my_cards = []
for i_cardamt in range(1, cards_per_hand + 1):
my_card = random.choice(deck)
my_cards.append(my_card)
deck.remove(my_card)
hands[i_hands] = my_cards
print(hands)
this is the code i made to shuffle the cards. I know i made a comepletely new set that's nothing to do witht the one on top.
how would I connect the last block to the one on top ?
my expected output is:
3 Hearts 3
4 Hearts 4
5 Hearts 5
6 Hearts 6
7 Hearts 7
8 Hearts 8
9 Hearts 9
10 Hearts 10
J Hearts 11
Q Hearts 12
K Hearts 13
A Hearts 14
#piece below should be randomized
Hand 1:
Hearts 1
Clubs J
Diamonds 3
Diamonds J
Clubs 1
Hand 2
Diamonds 5
Clubs K
Spades 4
Clubs 3
Clubs 6
this is what i normally get
2 Clubs 2
3 Clubs 3
4 Clubs 4
5 Clubs 5
6 Clubs 6
7 Clubs 7
8 Clubs 8
9 Clubs 9
10 Clubs 10
J Clubs 11
Q Clubs 12
K Clubs 13
A Clubs 14
2 Spades 2
3 Spades 3
4 Spades 4
5 Spades 5
6 Spades 6
7 Spades 7
8 Spades 8
9 Spades 9
10 Spades 10
J Spades 11
Q Spades 12
K Spades 13
A Spades 14
2 Diamonds 2
3 Diamonds 3
4 Diamonds 4
5 Diamonds 5
6 Diamonds 6
7 Diamonds 7
8 Diamonds 8
9 Diamonds 9
10 Diamonds 10
J Diamonds 11
Q Diamonds 12
K Diamonds 13
A Diamonds 14
2 Hearts 2
3 Hearts 3
4 Hearts 4
5 Hearts 5
6 Hearts 6
7 Hearts 7
8 Hearts 8
9 Hearts 9
10 Hearts 10
J Hearts 11
Q Hearts 12
K Hearts 13
A Hearts 14
{1: ['Hearts K', 'Diamonds 9', 'Hearts 6', 'Hearts 5', 'Clubs 9'], 2: ['Hearts 1', 'Diamonds 1', 'Hearts Q', 'Diamonds A', 'Diamonds 4']}