A program in computing is a set of instructions that tells a computer what to do. It's like a recipe for the computer, telling it exactly what steps to take to complete a specific task.
def draw_board(board):
"""Prints the current state of the game board."""
print(board[0] + '|' + board[1] + '|' + board[2])
print('-+-+-')
print(board[3] + '|' + board[4] + '|' + board[5])
print('-+-+-')
print(board[6] + '|' + board[7] + '|' + board[8])
def
check_winner(board, player):
"""Checks if the given player has won."""
winning_combos = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
for combo in winning_combos:
if all(board[i] == player for i in combo):
return True
return False