❌ Using two separate loops for colors. ❌ Forgetting to set the fill color before adding the rectangle. ❌ Off-by-one errors in the loop conditions. ❌ Hardcoding square size and board dimensions without using constants.
Ensure your loop boundaries use < array.length rather than <= array.length to avoid throwing out-of-bounds exceptions.
The most efficient way to determine the color is using the modulo operator (%). If (row + col) % 2 == 0, set the color to one choice (like black). Otherwise, set it to the second choice (like red). This ensures that every time you move one square to the right or one square down, the color flips, creating the perfect checkerboard pattern. Implementation Tips 9.1.7 Checkerboard V2 Codehs
if (row + col) % 2 == 0: pen.color("red") else: pen.color("black")
Solving 9.1.7 Checkerboard V2 is less about the act of placing markers and more about algorithmic thinking ❌ Using two separate loops for colors
For odd dimensions, the pattern must still alternate. The "X" and "O" example shows that createBoard([5, 4]) correctly handles an odd number of rows by ensuring the pattern alternates properly down the board.
Fill the grid coordinates with the required elements or color calls specified by your prompt instructions. Common Pitfalls and Troubleshooting ❌ Hardcoding square size and board dimensions without
Let me know what your console is saying!