I'm currently doing a python project that requires me to make a game; I have defined a class called Game
that when initialized takes P1
and P2
(Player
class instances).
I then defined a list called deck
, which then I shuffled and redefined as the new shuffled deck. The issue is when I print deck
it prints None
.
import random
class Game():
deck = []
def __init__(self, p1, p2):
self.p1 = p1
self.p2 = p2
self.__generateCards()
def __generateCards(self):
colors = ['red', 'black', 'yellow']
for x in range(0,3):
for y in range(1,11):
li = [colors[x], y]
self.deck.append(li)
self.deck = random.shuffle(self.deck)
print(self.deck)
Aucun commentaire:
Enregistrer un commentaire