i've been trying to get the sum of list that changed its values from a string to int using a function
player_hand = []
def card_type(player_hand):
card_value = 0
if player_hand[0] == 'A':
card_value = 11
if player_hand[0] == 'J':
card_value = 10
if player_hand[0] == 'Q':
card_value = 10
if player_hand[0] == 'K':
card_value = 10
if player_hand[0] == '2':
card_value = 2
if player_hand[0] == '3':
card_value = 3
if player_hand[0] == '4':
card_value = 4
if player_hand[0] == '5':
card_value = 5
if player_hand[0] == '6':
card_value = 6
if player_hand[0] == '7':
card_value = 7
if player_hand[0] == '8':
card_value = 8
if player_hand[0] == '9':
card_value = 9
if player_hand[0] == '1':
card_value = 10
def player_hit(card_deck):
rando = random.randint(0,len(card_deck)-1)
player_hand.append(card_deck[rando])
card_deck.remove(card_deck[rando])
and then try to find the sum of the player list using
card_total = 0
print('Player was handed:')
for i in range(2):
print(player_hit(card_deck))
for i in len(player_hand)-1:
print('\n',sum(card_type(player_hand[i])))
however i get an error
for i in len(player_hand)-1:
TypeError: 'int' object is not iterable
i don't understand what the problem is because ive taken the values and converted them into int's already as well as checked the list index range. Please help