Determining a Winner in Tic Tac Toe
<p>I'm looking to write a procedure in python for a 3x3 tic-tac-toe board called <code>winner(board)</code> that takes a 2-dimensional list representing a Tic-Tac-Toe board and determines if there is a winner (and if there is a winner, who it is) or if the game ends on a draw. The board uses <code>'-'</code> to represent an open position, <code>'x'</code> for player 1 and <code>'o'</code> for player 2.</p>

<p>I also wish to use the procedures <code>select_row(array, i)</code> and <code>select_col(array,i)</code>  which accept a 2-dimensional array (represented as a nested list) and an index of a row or column, and returns a list that represents the row or column associated with that index, as well as the procedures <code>select_main_diag(array)</code> and <code>select_counter_diag(array)</code> that accept a square 2-dimensional array and return a list with the elements of either the main diagonal or counterdiagonal (respectively).</p>

<p>Returns would be as follows:</p>

<pre><code>winner([['-','-','-'], ['-','-','-'], ['-','-','-']])
False

winner([['x','x','x'], ['-','-','-'], ['-','-','-']])
'x'

winner([['o', '-','-'], ['-', 'o','-'], ['-','-','o']])
'o'

winner([['-','-','x'], ['-','-','x'], ['-','-', 'x']])
'x'

winner([['x','o','x'], ['x','o','o'], ['o','x','x']])
"Draw"

winner([['x','o','x'], ['x','o','o'], ['o','-','x']])
False
</code></pre>

<p>And the procedures that I wish to include and use in the code are as follows:</p>

<pre><code>def select_row(lst, i):
 return lst[i]

def select_col(lst, i):
   return [lst[idx][i] for idx in range(len(lst))]

def select_main_diag(array):
  return [array[i][i] for i in range(len(array))]

def select_counter_diag(array): 
  return [array[len(array)-i-1][i] for i in range(len(array))]
</code></pre>

<p>I am completely new to using python and am quite unfamiliar with it, so any advice on this problem -- both how to go about it and how to put it into code -- would be quite helpful.</p>
