Tic-Tac-Toe

🎯 Find out which player won.

You are given a Tic-Tac-Toe playing field as a nested list:

ttt = [['X', 'O', 'X'],
       ['.', 'X', 'O'],
       ['X', 'O', 'O']]

Write a program that determines which player has three symbols in a row (or whether it is a draw).

Hints

  • Examine rows, columns and diagonals separately at first.

  • It gets a little easier when you leave out the inner brackets.

  • Test the code with several game situations.

Translated with www.DeepL.com