mercredi 9 décembre 2020

Shuffling a list inside an object in Python

Hello, I'm new to python oop. I'm trying to make a blackjack game, where I create object called cards and I whould like to shuffle the cards in pack in innit function, but random.shuffle(self.cards * self.number_of_packs) doesnt work, is there any way to do it inside innit function, or do I have to do it outside the Cards object?

class Cards:
    def __init__(self):
        import random
        self.onTable = []
        self.cards = ["2 ♥", "3 ♥", "4 ♥..."]
        self.number_of_packs = random.randint(2, 5)
        self.inPack = random.shuffle(self.cards * self.number_of_packs)




Aucun commentaire:

Enregistrer un commentaire