например, 1-я карта = 7, общая сумма = 7, 2-я. карта = 3, итого = 17 (должно быть 10)
Код: Выделить всё
# creating deck of cards
ranks = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']
rank_values = {
'A': 1,
'2': 2,
'3': 3,
'4': 4,
'5': 5,
'6': 6,
'7': 7,
'8': 8,
'9': 9,
'10': 10,
'J': 10,
'Q': 10,
'K': 10
}
# function to deal cards
def deal_card(person, total):
random_value = random.choice(ranks)
print(player, "card is", random_value)
# problem line below
total = total + rank_values[random_value]
return total
playertotal = 0
for i in range(2):
playertotal+=deal_card("player", playertotal)
print(playertotal)
Подробнее здесь: https://stackoverflow.com/questions/783 ... ded-values