First post here.
I'm trying to get the value of the cards in PlayersHand and add them.Then 'hit' a new card and add it to variable 'score'.
I've seen lots of options, including dicts and splits, but they don't make sense fully to me yet.
Is there a way using the (i) iteration to add the i's?
Thanks
I've just included a section of the code
I'm trying to get the value of the cards in PlayersHand and add them.Then 'hit' a new card and add it to variable 'score'.
I've seen lots of options, including dicts and splits, but they don't make sense fully to me yet.
Is there a way using the (i) iteration to add the i's?
Thanks
I've just included a section of the code
if option == 1: print ("Lets Play!") #+++++++++++++++++Deal and display cards++++++++++++++++# PlayersHand = random.choices(Deck, k=2) print(name,"Your cards are", PlayersHand) DealersHand = random.choices(Deck, k=1) print("Dealer, your cards are Blank +",DealersHand) total = 0 for i in PlayersHand: countval=(i[0])#to get the value of the card(needed first two values for one or ten print ("count is", countval); print("-------------") print(i) if countval == "J" or countval =="K" or countval =="Q": total +=10 elif countval =="A": total = 11 else: total=countval print ("countval is",countval) print ("countval is",total) print (PlayersHand) # print(PlayersHand.numval) #+++++++++++++++++Turn value into integer++++++++++++++++# def card_value(card): rank = Deck[0] if rank in Ranks[0:-4]: return int(rank) elif rank == 'ACE': return 11 else: return 10 print("card") print (rank) while sum(PlayersHand) <21: decide = input("Do you want to hit or stand?: H or S?") if decide == "H" or "h": PlayersHand.append(random.choices(Deck, k=1))