spades = ['2S','3S','4S','5S','6S','7S','8S','9S','10S','JS','QS','KS','AS']
hearts = ['2H','3H','4H','5H','6H','7H','8H','9H','10H','JH','QH','KH','AH']
clubs = ['2C','3C','4C','5C','6C','7C','8C','9C','10C','JC','QC','KC','AC']
diamonds = ['2D','3D','4D','5D','6D','7D','8D','9D','10D','JD','QD','KD','AD']
allCards = spades + hearts + clubs + diamonds
import random
random.shuffle(allCards)
bot1 = [allCards.pop() for i in range(2)]
print(bot1)
cardVal = {'2S':1,'3S':2,'4S':3,'5S': 4,'6S':5,'7S':6,'8S':7,'9S':8,'10S':9,'JS':10,'QS':11,'KS':12,'AS':13,
'2H':1,'3H':2,'4H':3,'5H': 4,'6H':5,'7H':6,'8H':7,'9H':8,'10H':9,'JH':10,'QH':11,'KH':12,'AH':13,
'2C':1,'3C':2,'4C':3,'5C': 4,'6C':5,'7C':6,'8C':7,'9C':8,'10C':9,'JC':10,'QC':11,'KC':12,'AC':13,
'2D':1,'3D':2,'4D':3,'5D': 4,'6D':5,'7D':6,'8D':7,'9D':8,'10D':9,'JD':10,'QD':11,'KD':12,'AD':13}
for i in bot1:
print(cardVal[i])
bot1hand = [cardVal[i]]
print(bot1hand)
我想將bot1
擁有的卡的值放在單獨的數組中,但遇到問題。我總是將兩個值分別打印在不同的行上,而數組bot1hand
僅存儲兩個值的最後一個值。如何從字典中提取數值到數組中
例如:
>>>
['AC', '5C']
13
4
[4]
>>>
downvote的任何特定原因? – idjaw