title: blackjack game for python
body: <p>I am making a blackjack game on Python for a school project. I have made the main part of my game but I keep getting a syntax error. I have tried to debug it, but I can not work out what is wrong.</p>
  
  <p>Here is my code - </p>
  
  <pre><code>def total(hand):
      aces = hand.count(11)
      t = sum(hand)
      if t &gt; 21 and aces &gt; 0:
          while aces &gt; 0 and t &gt; 21:
              t -= 10
              aces -= 1
      return t
  
  cards = [2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11]
  cwin = 0  
  pwin = 0  
  
  while True:
      player = []
      player.append(rc(cards))
      player.append(rc(cards))
      pbust = False  
      cbust = False  
      while True:
          tp = total(player)
          print "The player has these cards %s with a total value of %d" % (player, tp)
          if tp &gt; 21:
              print "--&gt; The player is busted!"
              pbust = True
              break
          elif tp == 21:
              print "\a BLACKJACK!!!"
              break
          else:
              hs = raw_input("Hit or Stand/Done (h or s): ").lower()
              if 'h' in hs:
                  player.append(rc(cards))
              else:
                  break
      while True:
          comp = []
          comp.append(rc(cards))
          comp.append(rc(cards))
  
          while True:
              tc = total(comp)                
              if tc &lt; 18:
                  comp.append(rc(cards))
              else:
                  break
          print "the computer has %s for a total of %d" % (comp, tc)
  
          if tc &gt; 21:
              print "--&gt; The computer is busted!"
              cbust = True
              if pbust == False:
                  print "The player wins!"
                  pwin += 1
          elif tc &gt; tp:
              print "The computer wins!"
              cwin += 1
          elif tc == tp:
              print "It's a draw!"
          elif tp &gt; 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 "Thanks for playing blackjack with the computer!"
  </code></pre>
  
  <p>I run 3.3.2 I have edited slightly and now get  this. </p>
  
  <p></p>