I'm trying to create a card game, I create a Deck object with a list of objects of the Card type. When I try to sort the list, I get a list with Objects of type NoneType.
import random
SUIT = {'C': 1, 'D': 2, 'H': 3, 'S': 4}
VALUE = {'A': 1, '2': 2, '3': 3,'4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13}
class Card:
def __init__(self, string):
self.v = VALUE[string[1]]
self.s = SUIT[string[0]]
class Deck:
def __init__(self):
self.__cards = [Card(f'{s}{v}') for s in SUIT.keys() for v in VALUE.keys()]
self.shuffle()
print(self.__cards)
def shuffle(self):
random.shuffle(self.__cards)
printing self.__cards return list of None, help me please. Thanks!
Aucun commentaire:
Enregistrer un commentaire