Python tic-tac-toe крестики-нолики 3Х3

Классические крестики нолики 3Х3. Функция должна возвращать в случае выигрыша символ победителя «Х» или «О». Если ничья (draw) — «D». На вход функции подается подобный 2-мерный массив список. Если клетка не заполнена, то символ «.»

game_result = [
        u»OOX»,
        u»XXO»,
        u»OXX»]

>>> def check_win(game_result):

# Column and row checking
>>>     for i in range(3):
>>>         if game_result[i][0] == 

               game_result[i][1] == 
               game_result[i][2]:
>>>             return game_result[i][0]
>>>         if game_result[0][i] == 
               game_result[1][i] == 
               game_result[2][i]:
>>>             return game_result[0][i]
# Diagonal checking

>>>     if game_result[0][0] == 
           game_result[1][1] == 
           game_result[2][2]:
>>>         return game_result[1][1]
>>>     if game_result[2][0] == 
           game_result[1][1] == 
           game_result[0][2]:
>>>         return game_result[1][1]
>>>     return «D»

Автор: Viktor