In [2]:
!pip install -q ipythonblocks
In [3]:
from ipythonblocks import BlockGrid
In [4]:
grid = BlockGrid(8, 8, fill=(0, 0, 0))
In [5]:
grid
Out[5]:

Color every other block white

In [6]:
grid[0,0]
Out[6]:
In [7]:
grid[0,1].red = 255
grid[0,1].green = 255
grid[0,1].blue = 255
In [8]:
grid
Out[8]:
In [ ]:
help(range)
In [10]:
for i in range(1, 8, 2):
    grid[0,i].red = 255
    grid[0,i].green = 255
    grid[0,i].blue = 255
In [11]:
grid
Out[11]:
In [12]:
for i in range(0, 8, 2):
    grid[1,i].red = 255
    grid[1,i].green = 255
    grid[1,i].blue = 255
In [13]:
grid
Out[13]:

Can we do loops within loops ?

In [16]:
for j in range (0, 8, 2):
    for i in range(1, 8, 2):
        grid[j,i].red = 255
        grid[j,i].green = 255
        grid[j,i].blue = 255
In [17]:
grid
Out[17]:
In [18]:
for j in range(1, 8, 2):
    for i in range(0, 8, 2):
        grid[j,i].red = 255
        grid[j,i].green = 255
        grid[j,i].blue = 255
In [19]:
grid
Out[19]:

Hurrah!!