Created
July 16, 2012 19:38
-
-
Save arnar/3124571 to your computer and use it in GitHub Desktop.
When you don't have a deck of cards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def makeDeck(): | |
ranks = 'Ace Two Three Four Five Six Seven Eight Nine Ten Jack Queen King'.split() | |
suits = 'Hearts Clubs Spades Diamonds'.split() | |
return ['%s of %s' % (r,s) for r in ranks for s in suits] | |
def draw(deck): | |
card = random.choice(deck) | |
deck.remove(card) | |
return card | |
print "%s -- %d cards left" % (draw(D), len(D)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment