[Tutor] Bug

Grace Sanford gsanford at wesleyan.edu
Wed May 17 12:26:39 EDT 2017

Theoretically, the following code is suppose to check if the user has won a
tic tac toe game by checking if there are all "X"s in either the
horizontal, vertical, or diagonal lines of a grid (represented by a list
with "board" with elements 0-8).  If one of these is the case, it is
suppose to print the "You won" string.  Nevertheless, when I change list
variable to reflect one of these conditions, there is no printing
occurring.  I cannot figure out why.

if board[0:3]==["X", "X", "X"] or board[3:6]==["X", "X", "X"] or
board[6:9]==["X", "X", "X"] or \
    [board[0],board[3],board[6]]==["X", "X", "X"] or
[board[1],board[4],board[7]]==["X", "X", "X"] or
[board[2],board[5],board[8]] ==["X", "X", "X"] or \
    [board[0],board[4],board[8]]==["X", "X", "X"] or
[board[2],board[4],board[6]]==["X", "X", "X"]:

More information about the Tutor mailing list