9.1.7 Checkerboard V2 Codehs -
If the row index is odd, the pattern must start with Color B.
Create an inner loop that iterates through the columns for each row. 9.1.7 Checkerboard V2 Codehs
If (row + col) % 2 != 0 , the cell gets the alternating value (e.g., 0, or the opposite color). Visual Example of Index Sums: Top-left cell: Row 0, Column 0 Next cell right: Row 0, Column 1 Next cell down: Row 1, Column 0 Diagonal cell: Row 1, Column 1 If the row index is odd, the pattern must start with Color B
To create a checkerboard, we use the row and column indices. If the sum of the and column index is even, we assign one value (e.g., 0); if it is odd, we assign the other (e.g., 1). This is easily checked using the modulo operator ( % ): if (row + col) % 2 == 0: (Sum is even) else: (Sum is odd) Step-by-Step Implementation Visual Example of Index Sums: Top-left cell: Row