[Tutor] Bug

Alan Gauld alan.gauld at yahoo.co.uk
Wed May 17 19:04:02 EDT 2017

On 17/05/17 17:26, Grace Sanford wrote:

> 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.

You need to show us the whole code including the print statements.
Also, do you get an error message? If so please include the full message.

As it stands the formatting is all messed up but unless you have it all
on one line (or 3 lines, I just noticed the \ chars...) I suspect you
will get a syntax error?

To fix that you can put parentheses round the expression:

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"]

Have you tried breaking it down in the interpreter?
Try an if statement with just the first three lines?
Then the last two? etc That will help identify where
the problem lies.

At a casual glance I can't see any issues with the
code above.

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list