I have this code to generate the list that contains the deck of Cards object instances:
import random
class Cards:
def __init__(self, Value = random.choice([1,2,3,4,5,6,7,8,9,10,11,12,13]), Group = random.choice(["Diamonds", "Hearts", "Clubs", "Spades"])):
self.Value = Value
self.Group = Group
def printCards(self):
if self.Value == 11:
print("J de " + self.Group)
elif self.Value == 12:
print("Queen de " + self.Group)
elif self.Value == 13:
print("King de " + self.Group)
else:
print(str(self.Value) + " de " + self.Group)
def creat_deck():
list_numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
list_groups = ["Diamonds", "Hearts", "Clubs", "Spades"]
list_deck = []
for number in list_numbers:
for group in list_groups:
list_deck.append(Cards(number, group))
return list_deck
print(creat_deck())
[<__main__.Cards object at 0x02D3D100>, <__main__.Cards object at 0x02D3D070>, <__main__.Cards object at 0x02D3DC70>, ...and so on until the Card object 52]
help me to get the actual cards like format as below:
[Queen of Diamonds, 7 of Clubs, , ...and so on]