title: Python - TicTacToe
body: <p>In this question I have to create a TicTacToe game in python which will run in terminal. This is a 2player game and if any player wins by the rules of TicTacToe, Winner =  player 1/2 has to be printed.</p>
  <p>I'm getting a winner statement when I have three 0's or 1's diagonally but I'm not getting winner in other two cases (horizontally and vertically)</p>
  <p>Please help find the error in my code</p>
  <pre><code>import numpy as np
  
  def create_board():
      return (np.array([[0, 0, 0],
                        [0, 0, 0],
                        [0, 0, 0]]))
  
  
  def coordinates(board, player):
      i, j, cn = (-1, -1, 0)
      while (i &gt; 3 or i &lt; 0 or j &lt; 0 or j &gt; 3) or (board[i][j] != 0):
          if cn &gt; 0:
              print(&quot;Wrong Input! Try Again&quot;)
          print(&quot;Player {}'s turn&quot;.format(player))
          i = int(input(&quot;x-coordinates: &quot;))
          j = int(input(&quot;y-coordinates: &quot;))
          i = i - 1
          j = j - 1
          cn = cn + 1
      board[i][j] = player
      return board
  
  
  def row_win(board, player):
      for x in range(len(board)):
          win = True
  
          for y in range(len(board)):
              if board[x, y] != player:
                  win = False
                  continue
      return win
  
  
  def col_win(board, player):
      for x in range(len(board)):
          win = True
  
          for y in range(len(board)):
              if board[y][x] != player:
                  win = False
                  continue
  
      return win
  
  
  def diag_win(board, player):
      win = True
      y = 0
      for x in range(len(board)):
          if board[x][x] != player:
              win = False
      if win:
          return win
      win = True
      if win:
          for x in range(len(board)):
              y = len(board) - 1 - x
              if board[x][y] != player:
                  win = False
      return win
  
  
  def evaluate(board):
      winner = 0
  
      for player in [1, 2]:
          if (row_win(board, player) or
                  col_win(board, player) or
                  diag_win(board, player)):
              winner = player
  
      if np.all(board != 0) and winner == 0:
          winner = -1
      return winner
  
  
  def play_game():
      board, winner, counter = create_board(), 0, 1
      print(board)
      while winner == 0:
          for player in [1, 2]:
              board = coordinates(board, player)
              print(&quot;Board after &quot; + str(counter) + &quot; move&quot;)
              print(board)
              counter += 1
              winner = evaluate(board)
              if winner != 0:
                  break
      return winner
  
  print(&quot;Winner is: &quot; + str(play_game()))
  </code></pre>