Skip to content

Instantly share code, notes, and snippets.

@arnar
Created July 16, 2012 19:38
Show Gist options
  • Save arnar/3124571 to your computer and use it in GitHub Desktop.
Save arnar/3124571 to your computer and use it in GitHub Desktop.
When you don't have a deck of cards
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