I'm just learning Python and am working on a Tic Tac Toe problem. When I'm trying to see if all the items in a row are the same, I originally did it via this:
if board[1] == board[4] == board[7]
This worked fine, but I quickly realized that I forgot to compare them to being an X or O. So I tried to change it to work like this:
if board[1] == board[4] == board[7] == ('X' or 'O')
This works if the line contains X's, but not if it contains O's. If I remove the X part, and just leave the O, then it works for O's. Is there a different way to do this and still keep it on one line?
I'm sure there's probably a much better way to do it in the first place, but I'm just wondering why this particular syntax doesn't work.