i have balckjack code, which does not run, i need some ones help, with tellings, wht the problem is. i have higlighted part of the code,were it stops.

below is the code.

from random import choice as rc

rc=randomcards
def total(hand):
        # aces in the hand
        aces = hand.count(11)
        # Aces count as 1 or 11
        # here is while loopwhich will ort it out for you
        t = sum(hand)
        # you have gone over 21 but there is an ace
        if t > 21 and aces > 0:
            while aces > 0 and t > 21:
                # it will now switch the ace from 11 to 1
                t -= 10
                aces -= 1
        return t
    
#assume blackjack has the following values
cards = [2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11]
     
    # there are 4 suits per deck and usually several decks
    # this way you can assume the cards list to be an unlimited pool
     
cwin = 0  # computer win counter
pwin = 0  # player win counter
while True:
        player = []
        # draw 2 cards for the player to start
        player.append(rc(cards))
        player.append(rc(cards))
        pbust = False  # player busted flag
        cbust = False  # computer busted flag
while True:
            # loop for the player's play ...
        tp = total(player)
print "The player has these cards %s with a total value of %d" % (player, tp)

if tp > 21:
                print "--> The player is busted!"
                pbust = True
                break


elif  tp == 21:
    

                print "\a BLACKJACK!!!"
                break
else:
                Hs = raw_input("Hit or Stick (h or s): ").lower()
                if 'h' in hs:
                    player.append(rc(cards))
                else:
                    break
while True:
            # loop for the computer's play ...
           comp = []
           [B] comp.append(rc(cards))
            comp.append(rc(cards))[/B]            # dealer generally stands around 17 or 18
while True:
                tc = total(comp)                
if tc < 18:
                    comp.append(rc(cards))
                else:
                    break
            print "the computer has %s for a total of %d" % (comp, tc)
            # now figure out who won ...
            if tc > 21:
                print "--> The computer is busted!"
                cbust = True
                if pbust == False:
                    print "The player wins!"
                    pwin += 1
            elif tc > tp:
               print "The computer wins!"
                cwin += 1
            elif tc == tp:
                print "It's a draw!"
            elif tp > tc:
                if pbust == False:
                    print "The player wins!"
                    pwin += 1
                elif cbust == False:
                    print "The computer wins!"
                    cwin += 1
            break
        print
        print "Wins, player = %d  computer = %d" % (pwin, cwin)
        exit = raw_input("Press Enter (q to quit): ").lower()
        if 'q' in exit:
            break
        print

    print "Thanks for playing blackjack with the computer!"

i have highlighted part of the code,were it stops.

What does 'stop' mean? What is the error message? The message will tell you what the problem is. Also, you want to consider breaking the program into functions so you don't have one large mess that you can't figure out. A good intro book is the first link that follows. Functions are section 4.6 and handling errors is covered in section 8
http://www.network-theory.co.uk/docs/pytut/ There are more Python books here
http://linkmingle.com/list/List-of-Free-Online-Python-Books-freebooksandarticles

the error message which it displays, is "error with syntax", the part of the code were the error is shown below:
comp.append(rc(cards))
comp.append(rc(cards))

if you see, my first post, you can see the full blackjack code,

thanks for ur help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.