# takes as input, hand, and returns a "dictionary" whose keys are
# the ranks and the values are the number of cards in the hand for
# the given rank
def process_ranks(hand):
drank = {}
for n in range(2,15):
drank[n] = 0
cards = hand.split(":")
convert = {'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'t':10,'j':11,'q':12,'k':13,'a':14}
for card in cards:
rank = card[0]
drank[convert[rank]] = drank[convert[rank]] + 1
return drank
d = process_ranks("2s:2c:4s:3c:6d")
print(d)
{2: 2, 3: 1, 4: 1, 5: 0, 6: 1, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0}
# takes as input, hand, and returns a "dictionary" whose keys are
# the suits and the values are the number of cards in the hand for
# the given suit
def process_suits(hand):
dsuit = {'s':0, 'c': 0, 'h':0, 'd':0}
cards = hand.split(":")
for card in cards:
suit = card[1]
dsuit[suit] = dsuit[suit] + 1
return dsuit
#2s:5s:4s:3s:6s
d = process_suits("2s:5c:4s:3c:6d")
print(d)
{'s': 2, 'c': 2, 'h': 0, 'd': 1}
xs = [10,11,12,13,14,15,16,17,18,19,20]
list(range(10,21))
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
drank = {}
for n in range(2,15):
drank[n] = 0
dsuit = {'s':0, 'c': 0, 'h':0, 'd':0}
dsuit = {}
for s in ['c','d','h','s']:
dsuit[s] = 0
"2s:5s:4s:3s:6s".split(':')
['2s', '5s', '4s', '3s', '6s']
convert = {'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'t':10,'j':11,'q':12,'k':13,'a':14}
convert['q']
12