Skip to content

Instantly share code, notes, and snippets.

@ChicagoDev
Created May 2, 2023 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChicagoDev/6ee9fbe7521e79797d344bcdb5e810af to your computer and use it in GitHub Desktop.
Save ChicagoDev/6ee9fbe7521e79797d344bcdb5e810af to your computer and use it in GitHub Desktop.
def check_win():
winner = None
# Vertical lines
if (board_squares[0][0].text == board_squares[0][1].text == board_squares[0][2].text) and board_squares[0][2].text in ["X", "O"]:
winner = board_squares[0][0]
# Horizontal lines
elif (board_squares[0][0].text == board_squares[1][0].text == board_squares[2][0].text) and board_squares[2][0].text in ["X", "O"]:
winner = board_squares[0][0]
# Diagonals
elif (board_squares[0][0].text == board_squares[1][1].text ==
board_squares[2][2].text) and board_squares[2][2].text in ["X", "O"]:
winner = board_squares[0][0]
if winner is not None:
player_turn_text.value = winner.text + " wins!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment