Python - iteration and adding to a score

Hello. I’m looking for help on the countval part

I’ve ’ BOLDED’  the bit in the code below.

But there are lots of glitches.

The question concerns adding the ‘rank’ of the cards together to a total and using that to make a score.

I’ve seen other ways but I don’t get them yet.

I think this can work but missing a step or 3.


import random

PlayersHand = []
DealersHand = []
Ranks = ["2", "3", "4", "5", "6", "7", "8", "9", "10","Ace", "Jack", "Queen", "King"]
Suits = ["Hearts", "Diamonds", "Clubs", "Spades"]
Deck = []
for num in Ranks:
    for suit in Suits:
# print(num, suit)
        card = num + ' of ' + suit
        Deck += [card]


for i in Deck:
    numval=(i[0]) #to get the value of the card(needed first two values for one or ten)
# print ("numval is", numval)

#def getCardVal(): #struggled with this
# if numval.isdigit():
# return int(numval)
# elif numval == "A":
# return 1
# else:
# return 10

#if num == "Jack" or "Queen"or "King"
# num = 10

        #+++++++++++++++++INTRODUCTION AND OPTIONS FOR PLAY++++++++++++++++#

name = input ("please input your name: ")
print("Hi", name, "welcome to Blackjack")

print("please choose an option")

print("Press 1 to Play Game, 2 to read instructions, 3 to quit")

option = int(input("Make your choice: "));

        #+++++++++++++++++PLAY THE GAME++++++++++++++++#
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
                return 10
                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))

                print ("you got a" , PlayersHand, "your hand is now:", sum(PlayersHand))

                if total == 21:
                    print ("That's a win!");
                elif total <21:
                    print ("Hit or Stand");
                else :
                    print ("BUST")