title: Tic tac toe game Type error None python
body: <p>Hi I am trying to create a tic tac toe game with the <code>board</code> values <code>["0", "1", "2", "3", "4", "5", "6", "7", "8"]</code> coming from the front end and going back to the back end and then all this values being returned to the front end with a X from the user or a 0 from the random maths.
  The first time I input a value, it works, but the second time I input a value I get this error.</p>
  
  <pre><code>if board[cell1]  == char and board[cell2] == char and board[cell3] == char:
  TypeError: 'NoneType' object is not subscriptable
  </code></pre>
  
  <p>The error sounds like that the board list disappears but when I print the board on my codes it shows that the board is there.</p>
  
  <pre><code>def tic(request):
  
     if request.method == 'POST':
        body_unicode = request.body.decode('utf-8')
  
        body = json.loads(body_unicode)
  
        input_str = body['value']
  
        input = int(input_str)
  
        board = body['x']
        print(board) # Here I see the board is always there
  
  
        if board[input] != 'x' and board[input] != 'o':
           board[input] = 'x'
  
           if check_match(board,'x') == True:
              winner = 'x'
              return JsonResponse({'input': input, 'board': board, 'winner': winner})
  
           board = opponent_fun(board)
           if check_match(board,'o') == True:
              winner = 'o'
              return JsonResponse({'input': input, 'board': board, 'winner': winner})
  
           else:
              winner = 0
              return JsonResponse({'input': input, 'board': board, 'winner': winner})
        else:
           return JsonResponse({'taken' : 'place already taken'})
  
  
  def opponent_fun(board):
        random.seed()
        opponent = random.randint(0, 8)
  
        if board[opponent] != 'o' and board[opponent] != 'x':
           board[opponent] = 'o'
           return board
  
        else:
           opponent_fun(board)
  
  
  def check(board, char, cell1, cell2, cell3):
      if board[cell1]  == char and board[cell2] == char and board[cell3] == char:
          return True
  
  def check_match(board,char):
      if check(board,char, 0,1,2):
          return True
      if check(board,char, 3,4,5):
          return True
      if check(board,char, 6,7,8):
          return True
      if check(board,char, 2,4,6):
          return True
      if check(board,char, 0,4,8):
          return True
      if check(board,char, 1,4,7):
          return True
      if check(board,char, 2,5,8):
          return True
      if check(board,char, 6,7,8):
          return True
  </code></pre>