Skip to content Skip to sidebar Skip to footer

Nested For Loop Chess Board Coloring Not Working Python

I'm trying to make a chess game in python and to draw the boards, I'm using nested for loops. the problem I'm encountering is that when it comes to coloring the board, the logic I'

Solution 1:

You need to change the color of the even cells in the even lines and the color of the odd cells in the even odd lines:

if j % 2 == 0:

if (i+j) % 2 == 0:
    square.fill((238, 238, 210))
else:
    square.fill((118, 150, 86))

Post a Comment for "Nested For Loop Chess Board Coloring Not Working Python"