Skip to content

Instantly share code, notes, and snippets.

@spaghettiSyntax
Created December 7, 2017 06:36
Show Gist options
  • Save spaghettiSyntax/8a3a0ad334f547a80ca2328a97892459 to your computer and use it in GitHub Desktop.
Save spaghettiSyntax/8a3a0ad334f547a80ca2328a97892459 to your computer and use it in GitHub Desktop.
Tony Gaddis Python: Card Deal Excercise
# This program deals a random 5 card draw.
# Edit program further to allow user to discard and pull new cards, as well.
import random
values = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
suits = ['Heart', 'Spade', 'Clubs', 'Diamonds']
HAND_SIZE = 5
print('We will deal a random hand of', HAND_SIZE, 'cards')
hand = ['XX'] * HAND_SIZE
# pick 5 cards
i = 0
while i < HAND_SIZE:
value = random.randrange(len(values))
suit = random.randrange(len(suits))
card = values[value] + suits[suit]
print(card, end = ' ')
if card not in hand:
hand[i] = card
i += 1
print()
print(hand)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment