将变量值分配为字典的键

时间:2019-01-15 13:36:02

标签: python dictionary

hand_1 = ['J', 'A']
one = dict()
for card in hand_1:
    if card == 'J' or card == 'Q' or card == 'K': 
        one.update(card=10)

我是python初学者。更新字典时,我想将变量值的值分配为键。我能做什么?在上面的代码中,它将分配“卡”作为键,但我要获得卡的值。我该怎么办?

0 个答案:

没有答案