With single line numpy code without loop:
import numpy as np chessbool = (np.arange(3)[:, None] + np.arange(3)) % 2 == 0
and output:
array([[ True, False, True], [False, True, False], [ True, False, True]]
To populate an array of W and B :
chessboard = np.where(chessbool,'B','W')
and output:
array([['B', 'W', 'B'], ['W', 'B', 'W'], ['B', 'W', 'B']])
source share