-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcards.py
More file actions
48 lines (28 loc) · 826 Bytes
/
cards.py
File metadata and controls
48 lines (28 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
###########################
## dictionary for users
## dictionary keys = usernames
## dict value = hand
##
##
## shuffle deck
## pop 5 cards for each player
## print out what hands are
## extra credit: implement first unique character in a word (from memory)
##########################
import random
from collections import namedtuple
Card = namedtuple('Card', ['suit', 'value'])
suits = ['Diamonds', 'Hearts', 'Spades', 'Clubs']
face_cards = ['Jack', 'Queen', 'King', 'Ace']
values = list(range(2, 11))
values.extend(face_cards)
new_deck = []
for suit in suits:
for value in values:
card = Card(suit, value)
new_deck.append(card)
random.shuffle(new_deck)
pick = new_deck.pop()
#print(f'You picked {pick[1]} of {pick[0]}')
print(f'{pick.value} of {pick.suit}')