class Card:
def __init__(self, suit, value):
self.suit = suit
self.value = value
def show(self):
# print(f"{self.value} of {self.suit}")
return (self.suit, self.value)
class Deck(Card):
"""
Deck is collection of 52 cards.
"""
colour = ('Hearts', 'Diamonds', 'Spades', 'Clubs')
rank = ('Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace')
def __init__(self):
d = []
for s in Deck.colour:
for r in Deck.rank:
c = Card(s,r)
d.append(c)
self.pack = d
def draw(self):
return self.pack.pop()
mydeck = Deck()
j =1
for i in mydeck.pack:
print(j, "\t", mydeck.draw().show(), " count remaining ", len(mydeck.pack))
j +=1
while trying to print the contents of mydeck.deck
, which is a list, it only prints half of total values. If run again it prints next half of values.
Please help me to figure out why all content is not printed?
I am a beginner and any feedback is very much appreciated. Thanks in advance.