9.1.6 Checkerboard V1 Codehs Jun 2026

Make sure you are using Color.red and Color.gray (or whatever specific colors your assignment instructions require).

To solve this, you need to understand two fundamental concepts:

Below are two versions of the Python code to achieve this.

# Pass this function a list of lists to print it as a grid def print_board ( board ): for i in range(len(board)): print( " " .join([str(x) for x in board[i]])) # 1. Start with an empty board and fill it with 0s board = [] for i in range( 8 ): board.append([ 0 ] * 8 ) # 2. Use nested loops to change 0s to 1s in the correct rows for i in range( 8 ): for j in range( 8 ): # Top 3 rows (0, 1, 2) and bottom 3 rows (5, 6, 7) if i < 3 or i > 4 : board[i][j] = 1 # 3. Print the final result print_board(board) Use code with caution. Copied to clipboard 9.1.6 checkerboard v1 codehs

In CodeHS V1, you are often working with a Grid object. Remember that grid.set(row, col, value) is the standard syntax. If your specific assignment uses or Graphics , you would replace grid.set with putBall() or new Rect() , but the nested loop logic remains identical. Common Pitfalls

This version uses a Python shortcut to generate a row more concisely.

This code creates the simple, solid-row board described in the problem. Make sure you are using Color

. This ensures that adjacent cells never have the same value, creating the classic checkerboard look. 4. Print the Result Finally, pass your populated list to the provided print_board function to visualize the grid in the console. Example Solution Code

Always declare loop variables using var (e.g., for (var r = 0; ...) ). Forgetting var can leak the variable into global scope, breaking the nested loop logic.

Try implementing this yourself using the logic above. If you get stuck, ask your teacher or a classmate for help — working through the logic is how you learn best! Start with an empty board and fill it

Use an if statement to check if the row index i is less than 3 or greater than 4.

5. Troubleshooting: "You should set some elements of your board to 1"