-
Notifications
You must be signed in to change notification settings - Fork 0
/
Method2.py
43 lines (33 loc) · 992 Bytes
/
Method2.py
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
38
39
40
41
42
43
import random
# Method 2
# In this method we also get the same thing but the difference is that we know what card we got and its rank and value
cards = []
suits = ["Spades","clubs","hearts","diamonds"]
ranks = [{"rank":"A","value":11,
"rank":"1","value":1,
"rank":"2","value":2,
"rank":"3","value":3,
"rank":"4","value":4,
"rank":"5","value":5,
"rank":"6","value":6,
"rank":"7","value":7,
"rank":"8","value":8,
"rank":"9","value":9,
"rank":"J","value":10,
"rank":"Q","value":10,
"rank":"K","value":10,}]
for suit in suits:
for rank in ranks:
cards.append([suit,rank])
random.shuffle(cards)
def shuffle():
random.shuffle(cards)
def deal(number):
cards_dealt = []
for x in range(number):
card = cards.pop()
cards_dealt.append(card)
return cards_dealt
shuffle()
card = deal(1)[0]
print(card)