Free Friday 1-9-2026

Today in class I made tic-tac-toe.

This is the code for the board:

board = ["-", "-", "-",
         "-", "-", "-",
         "-", "-", "-"]

This is the code for printing the game board:

def printBoard(board):
    print(board[0] + " | " + board[1] + " | " + board[2])
    print("----------")
    print(board[3] + " | " + board[4] + " | " + board[5])
    print("----------")
    print(board[6] + " | " + board[7] + " | " + board[8])

This is the code for checking for wins:

This is the code for switching players:

def switchPlayer():
    global currnetPlayer
    if currnetPlayer == "X":
        currnetPlayer = "O"
    else:
        currnetPlayer = "X"

CATEGORIES:

Tags:

No Responses

Leave a Reply

Your email address will not be published. Required fields are marked *