-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaying_card.py
More file actions
27 lines (23 loc) · 952 Bytes
/
playing_card.py
File metadata and controls
27 lines (23 loc) · 952 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
# 'A♠', '2♠', '3♠', '4♠', '5♠', '6♠', '7♠', '8♠', '9♠', '10♠', 'J♠', 'Q♠', 'K♠',
# 'A♥', '2♥', '3♥', '4♥', '5♥', '6♥', '7♥', '8♥', '9♥', '10♥', 'J♥', 'Q♥', 'K♥',
# 'A♦', '2♦', '3♦', '4♦', '5♦', '6♦', '7♦', '8♦', '9♦', '10♦', 'J♦', 'Q♦', 'K♦',
# 'A♣', '2♣', '3♣', '4♣', '5♣', '6♣', '7♣', '8♣', '9♣', '10♣', 'J♣', 'Q♣', 'K♣'
# playing card unicode: https://en.wikipedia.org/wiki/Playing_cards_in_Unicode
import random
def playing_card():
suit = ("\u2660", "\u2665", "\u2666", "\u2663")
# print(suit)
# rank = 'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'
rank = list("A23456789") + ["10"] + list("JQK")
# print(rank)
deck = []
for s in suit:
for r in rank:
deck.append(r + s)
return deck
d = playing_card()
print(d)
random.shuffle(d)
print(d)
p = random.sample(d, 3)
print(p)