Python prints memory location instead of list. My code:
import random
class Card:
def __init__(self, value, suit):
self.value = value
self.suit = suit
def show_card(self):
print(self.value, self.suit)
def get_value(self):
if self.value > 10:
return 10
return int(self.value)
class Deck:
def __init__(self):
self.cards = []
self.build()
def build(self):
for suit in ["♣", "♦", "♥", "♠"]:
for value in range(2, 15):
self.cards.append(Card(suit, value))
return self.cards
def shuffle_deck(self):
random.shuffle(self.cards)
return self.cards
Deck().build()
deck = Deck().shuffle_deck()
print(deck)
The problem is when I append "Card" object to "cards" list. How could I print "cards" list elements instead of memory locations?