class HandOfCards:
def __init__ (self, numCardsInHand):
self.list = []
all_rank = random.randint(1, 13)
random_suit = ['d', 'c', 'h', 's']
all_suit = random.choice(random_suit)
for count in range(numCardsInHand):
self.list.append(Card(all_rank, all_suit))
def __str__(self):
all_items = '\n'.join(map(str, self.list))
return all_items
I'd like to create a number of random objects, but with the loop
for count in range(numCardsInHand):
self.list.append(Card(all_rank, all_suit))
it turned out I actually created numCardsInHand of exactly same objects. It seems like that the random module doesn't work on my for loop. I have problem figuring it out.