Exercise 7: Let's make Tic-Tac-Toe Game
Explore how to implement a tic-tac-toe game in Python by creating a grid, handling player inputs safely, and verifying winning conditions through vertical, horizontal, and diagonal checks. This lesson helps you apply safe programming techniques while managing game state and user interaction.
Problem statement
Tic-tac-toe is a two-player game that has crosses (Xs) and noughts (Os). Players take turns marking the free spaces in a 3x3 grid with X or O. The winner is the one who successfully fills the spaces with their marks in a horizontal, vertical, or diagonal line before the other player.
Your task is to create the game in Python.
Let’s start by creating the grid.
Task 1: Create the 3x3 grid
Input:
rowSize=3
colSize=3
Output:
The output should be the list of three lists (each list pointing to each row).
...