17.Tic-Tac-Toe.py
import tkinter as tk from tkinter import messagebox # Initialize current player as "X" and set winner flag to False current_player = "X" winner = False # Function to check for a winner def who_wins (): global winner # List of winning combinations for combo in [[ 0 , 1 , 2 ], [ 3 , 4 , 5 ], [ 6 , 7 , 8 ], [ 0 , 3 , 6 ], [ 1 , 4 , 7 ], [ 2 , 5 , 8 ], [ 0 , 4 , 8 ], [ 2 , 4 , 6 ]]: # Check if the buttons in the current combination have the same text and are not empty if buttons[combo[ 0 ]][ "text" ] == buttons[combo[ 1 ]][ "text" ] == buttons[combo[ 2 ]][ "text" ] != " " : # Highlight the winning combination with a green background buttons[combo[ 0 ]].config( bg = "green" ) buttons[combo[ 1 ]].config( bg = "green" ) buttons[combo[ 2 ]].config( bg = "green" ) # Show a message box declaring the winner ...