I'm a student doing Python for the first time, and my professor has directed me to Stack for guidance.
I am trying to simulate a deck of cards that can be shuffled, create a hand of 15, then check the hand to see if there is three of a kind within it.
I've added the code I have so far used to create the deck, shuffle, and create a hand. I understand there are multiple ways to go about this. Would it make sense to create a list where each value acts as a counter for the card number/value? And if yes, then how would I go about it?
#imoport dataframes
import random
import numpy
#create a list for card values
values = ['2','3','4','5','6','7','8','9','Jack','Queen','King','Ace']
#create a list for card suits
suits = ['Hearts', 'Clubs', 'Diamonds', 'Spades']
#create a list of lists called deck.
#inner brackets creates three values: x of y title (value0), value (value1), and suit (value2)
#outer brackets iterate through suits and values
deck = [[v + ' of ' + s,v,s] for s in suits for v in values]
#shuffle the deck
random.shuffle(deck)
#get a hand of the first 15 cards in the newly shuffled deck to create a hand
hand = deck [0:15]
#convert hand to a 2d numpy array
hand = numpy.array(hand)
#make a new 1 dimensional numpy array
#that is just the second column of hand
newhand = hand[:,1]
#create variables unique and count. unique is all of the unique values in newhand and count is a count of those values
unique, counts = numpy.unique(newhand, return_counts=True)
#make an array to see whether the hand contains a three of a kind
value_counter = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] #creating a new list to count each value found within our hand
#(based on index, ex: value_counter[0] represents the count of values[0] which=='2')