title: simplegui indentation error: SyntaxError: bad input (' ')
body: <p>I'm doing a mini-project on Coursera and I can run most parts of my code. However there's an error in the critical part about the game's <code>match or not</code> checking.</p>
  
  <pre><code># implementation of card game - Memory
  
  import simplegui
  import random
  
  # helper function to initialize globals
  def new_game():
      global turns, state, pairs, cards
      turns = 0
      state = 0
      pairs = []
      cards = range(9) * 2
      random.shuffle(cards)
  
  # define event handlers
  def mouseclick(pos):
      # add game state logic here
      global turns, state, pairs
      pointed = pos[0] // 50
      if  pointed in pairs:
          pass
      else:
          if state == 0:
              state = 1
              pairs.append(pointed)
          elif state == 1:
              state = 2
              turns += 1
              label.set_text('Turns =' + str(turns))
              pairs.append(pointed)
  #                if cards[pairs[-2]] == cards[[pairs[-1]]:
  #                    flag = True
  #                else:
  #                    flag = False
          else:
              state = 1
              if flag == False:
                  del pairs[-2:]
              pairs.append(pointed)
  
  # cards are logically 50x100 pixels in size    
  def draw(canvas):
      for n in range(1, 16):
          canvas.draw_line((n * 50, 0), (n * 50, 100), 1, 'Green')
  
      for n in pairs:
          canvas.draw_line((n * 50 + 25, 0), (n * 50 + 25, 100), 50, 'White')
  
      for n in pairs:
          canvas.draw_text(str(cards[n]), (n * 50 + 15, 65), 50, 'Black')
  
  
  # create frame and add a button and labels
  frame = simplegui.create_frame("Memory", 800, 100)
  frame.set_canvas_background('Red')
  frame.add_button("Reset", new_game)
  label = frame.add_label("Turns = 0")
  
  # register event handlers
  frame.set_mouseclick_handler(mouseclick)
  frame.set_draw_handler(draw)
  
  # get things rolling
  new_game()
  frame.start()
  
  # Always remember to review the grading rubric
  </code></pre>
  
  <p>I commented out Line 31 to 34 and that's the part where I have a problem. The console keeps telling me <code>Line 31: SyntaxError: bad input ('                ')</code> but I think the indentation is correctly made.</p>
  
  <p>Please help me figure out why it's a 'bad input', thanks a lot!</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Thanks to Russell's help, this function works now.</p>
  
  <pre><code># define event handlers
  def mouseclick(pos):
      # add game state logic here
      global turns, state, pairs, flag
      pointed = pos[0] // 50
      if pointed in pairs:
          pass
      else:
          if state == 0:
              state = 1
              pairs.append(pointed)
          elif state == 1:
              state = 2
              turns += 1
              label.set_text('Turns =' + str(turns))
              pairs.append(pointed)
              if cards[pairs[-2]] == cards[pairs[-1]]:
                  flag = True
              else:
                  flag = False
          else:
              state = 1
              if flag == False:
                  del pairs[-2:]
              pairs.append(pointed)
  </code></pre>