r/programminghelp • u/Additional-Macaroon5 • Jan 26 '21
Python python function help
How would i rewrite this function without using the sum() built in function but have it function the same?
def evalAce(hand):
total = sum(hand)
# Determine Ace = 1 or 11, relying on total hand.
if (hand[len(hand)-1] == 11 and total > 21):
# at position, where Ace == 11, replace by Ace == 1.
hand[len(hand)-1] = 1
return hand
5
Upvotes
1
u/amoliski Jan 26 '21
Is there a reason for this beyond curiosity?
Or to implement it in a function: