DEV Community

Discussion on: A Simple Python Tic-Tac-Toe Game Using Pygame

Collapse
 
djungarik profile image
Timur Berezhnoy • Edited

Checking rows and columns doesn't work, so I changed some lines a little bit. It works properly now.

# Checking rows
for row in range(0,3):
    if (game_array[row][0][2] == game_array[row][1][2] == game_array[row][2][2]) and game_array[row][0][2] != "":
        display_message(game_array[row][0][2].upper() + " has won!")
        return True

# Checking columns
for col in range(0, 3):
    if (game_array[0][col][2] == game_array[1][col][2] == game_array[2][col][2]) and game_array[0][col][2] != "":
        display_message(game_array[0][col][2].upper() + " has won!")
        return True
Enter fullscreen mode Exit fullscreen mode
Collapse
 
ramakm profile image
Ramakrushna Mohapatra

Worked for me. may be version issue. Thanks for your comment.