import random from card import Card class Deck: #data - list of 52 cards #constructor will create 52 cards def __init__(self): self.cards = [] self.numdealt = 0 #outer loop 1 - 4 # inner loop 2 - 14 for i in range(4): for j in range(2, 15): c = Card(j, (i+1)) self.cards.append(c) #draw - returns top card of the deck def draw(self): if self.numdealt > 51: print "All cards dealt" return 0 topcard = self.cards[self.numdealt] self.numdealt += 1 return topcard #shuffle - randomize the list of cards def shuffle(self): for i in range(len(self.cards)): num = random.randint(0, 51) self.cards[num], self.cards[i] = self.cards[i], self.cards[num] #display def display(self): for i in range(len(self.cards)): self.cards[i].printCard()