title: Find the result of tic-tac-toe in Python
body: <p>I am trying to write an function which displays who is the winner in the game of tic tac toe.
  If X is the winner it returns <code>X</code>, If O is the winner it returns <code>O</code> and for a draw, it returns boolean <code>None</code>
  What I tried works for some cases and fails for test cases given below Please help .</p>
  <pre><code>def check_winner(tuples):
      for row in range(0, len(tuples)):
          print(tuples[row])
          for col in range(0,3):
  
              #check for row win
              if tuples[row][0] == tuples[row][1] == tuples[row][2]:
                  print(&quot;1 &quot;)
                  # return tuples[row][0];
              #check for col win
              if tuples[0][col] == tuples[1][col] == tuples[2][col]:
                  print(&quot;2&quot;)
                  return tuples[row][0];
              # For diagonal
              if tuples[0][0] == tuples[1][1] == tuples[2][2]:
                  return tuples[0][0]
              if tuples[0][2] == tuples[1][1] == tuples[2][0]:
                  return tuples[2][0]
  </code></pre>
  <p>For test cases below</p>
  <pre><code># O wins
  test1 = (('X', 'O', 'O'),
          (None, 'O', 'X'),
          ('X', 'O', 'X'))
  # X Wins
  test2 = (('X', 'X', 'O'),
          ((&quot;O&quot;, 'X', 'O'),
          ('O', 'X', 'X'))
  </code></pre>
  <p>Calling function</p>
  <pre><code>print(check_winner(test1))
  print(check_winner(test2))
  </code></pre>
  <p>should return O and X respectively</p>