View Single Post
Old Oct 31st, 2005, 8:30 AM   #6
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by coldDeath
EDIT: i've set it to reshuffle when thw number of cards to deal is less than the number of cards left in the pack.
Make sure you repopulate the cards; my code removes cards from the pack, just as a dealer would.

Also, you might want to think about representing the cards as objects, rather than strings:
class Card:
   def __init__(self, suite, number):
      self.suite = suite
      self.number = number

   def __str__(self):
      return "%s of %s" % (self.number, self.suite)
This would give you more control over the deck of cards. e.g.:
remaining_hearts = [card for card in self.pack if card.suite = "Hearts"]
Of course, it depends on how complicated you wish to make your program, and what you're going to use it for.
Arevos is offline   Reply With Quote