Respuesta :
numbers = input("Enter your numbers: (comma separated) ")
lst = numbers.split(",")
num_lst = ([])
for i in lst:
num_lst.append(int(i))
total = num_lst[0]
num_lst.pop(0)
player_hand = ([num_lst[0], num_lst[1], num_lst[2]])
num_lst.pop(0)
num_lst.pop(0)
num_lst.pop(0)
dealer_hand = ([])
for w in num_lst:
if num_lst.index(w) % 2 == 0:
player_hand.append(w)
else:
dealer_hand.append(w)
is_player = True
zero_count = 0
while True:
if is_player:
if player_hand[0] == 9:
total += 0
elif player_hand[0] == 4:
total -= 10
elif player_hand[0] == 0:
if total + 11 < 100 and zero_count == 0:
total += 1
else:
total += 1
else:
total += player_hand[0]
player_hand.pop(0)
if total > 99:
print("Total: {}. The dealer is the winner as the card value exceeded when the player was dealing the card.".format(total))
break
is_player = False
elif not is_player:
if dealer_hand[0] == 9:
total += 0
elif dealer_hand[0] == 4:
total -= 10
elif dealer_hand[0] == 0:
if total + 11 < 100 and zero_count == 0:
total += 1
else:
total += 1
else:
total += dealer_hand[0]
dealer_hand.pop(0)
if total > 99:
print("Total: {}. The player is the winner as the card value exceeded when the dealer was dealing the card.".format(total))
break
is_player = True
I hope this helps!