9.1.7 Checkerboard | V2 Codehs
: You must use a loop inside another loop—typically an outer loop for the rows and an inner loop for the columns—to traverse every coordinate in the grid.
rl.question("Rows: ", (rows) => rl.question("Cols: ", (cols) => rows = parseInt(rows); cols = parseInt(cols); for (let i = 0; i < rows; i++) let line = ""; for (let j = 0; j < cols; j++) if ((i + j) % 2 === 0) line += "X"; else line += "O"; 9.1.7 Checkerboard V2 Codehs
Once you understand the toggle-and-reset pattern, you can adapt this code to draw any tile-based pattern (chessboards, game boards, pixel art, etc.). : You must use a loop inside another
Show how to do this in if you are in the Nitro/Java course board = [] for i in range(8): board
Create an empty list and fill it with eight sub-lists, each containing eight zeros. board = [] for i in range(8): board.append([0] * 8) Use code with caution. Copied to clipboard
To further develop their skills, students can explore variations and extensions of the Checkerboard V2 project:
: (row + col) % 2 == 0 checks if the sum is even → one color; odd → other color.

