Dec-21-2021, 04:13 PM
What you're missing is a loop to test for more than one eleven. Here's a suggestion:
def get_hand_value(*args): hand_total = sum (args) total_elevens = args.count (11) while total_elevens > 0 and hand_total > 21 : total_elevens -= 1 hand_total -= 10 if hand_total < 21 : return "The value of your hand is {0}".format(hand_total) elif hand_total > 21 : return "Busted!" else: return "Winner Winner Chicken Dinner!" #----------------------------------------------------------------------------- # While testing the execution of your program, I will use the hands below: hand_1 = get_hand_value(4,4,4,4) hand_2 = get_hand_value(11,10) hand_3 = get_hand_value(11,5,6,4,11,4) hand_4 = get_hand_value(11,5,6,10) hand_5 = get_hand_value(10,5,7) hand_6 = get_hand_value(5,6,5,10) hand_7 = get_hand_value(10,11) hand_8 = get_hand_value(11,11,11,11,10,10) hand_9 = get_hand_value(5,6,5,5) print(hand_1) print(hand_2) print(hand_3) print(hand_4) print(hand_5) print(hand_6) print(hand_7) print(hand_8) print(hand_9)
Output:The value of your hand is 16
Winner Winner Chicken Dinner!
Winner Winner Chicken Dinner!
Busted!
Busted!
Busted!
Winner Winner Chicken Dinner!
Busted!
Winner Winner Chicken Dinner!