0
def all_num_change(list):
    newlist = list
    num_of_a = 0
    for i in range(len(newlist)):
        if newlist[i] == 'A':
            num_of_a += 1
            newlist[i] = 11
    if sum(newlist) > 21:
        for i in range(len(newlist)):
            if newlist[i] == 11:
                newlist[i] = 1
    return newlist

Writing blackjack. Trying to separate the display array and backend calculating list. I think going through this function could get me a new list without effecting the old one which I could show the 'A's in front of players. but it just write in the list anyway. (list = newlist)

krmogi
  • 2,279
  • 1
  • 8
  • 25
Lia Li
  • 1

0 Answers0