9.1.6 Checkerboard V1 Codehs Online

: Forgetting that the middle two rows (index 3 and 4 in an 8-row grid) must remain empty (0s). Bypassing Assignment

: Create an 8x8 grid (list of lists) representing a game board. Specific Pattern top 3 rows bottom 3 rows should contain 1s. middle 2 rows should contain only 0s. Output Requirement : Use a provided print_board function to display the grid in a human-readable format. Key Logical Steps Initialize the Board : Create an empty list, typically named Fill the Top Rows

Ensure xPos uses the column variable ( c ) and yPos uses the row variable ( r ). Reversing them will flip your grid mapping logic. 9.1.6 checkerboard v1 codehs

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

) to create a grid pattern. In the 9.1.6 Checkerboard assignment, the goal is to alternate colors (usually black and red) across a grid of squares. Key Concepts Nested Loops : You use an outer loop for the and an inner loop for the : Forgetting that the middle two rows (index

Is your print_board function printing the modified board variable? If you'd like, I can:

Here is the completed code for the relevant section: middle 2 rows should contain only 0s

for row in range(8): row_list = [] for column in range(8): # Check if the current row is in the top 3 (row < 3) or bottom 3 (row > 4) if row < 3 or row > 4: # Create an alternating pattern by checking if (row + column) is even if (row + column) % 2 == 0: row_list.append(1) else: row_list.append(0) else: # The middle rows (index 3 and 4) are all blank (0's) row_list.append(0) board.append(row_list)

# Create an 8x8 grid filled with 0s board = [] for i in range(8): board.append([0] * 8) # Populate the board with a checkerboard pattern for i in range(8): for j in range(8): # The logic: if the sum of indices is even, set it to 1 if (i + j) % 2 == 0: board[i][j] = 1 else: board[i][j] = 0 # Print the board in the required format for row in board: print(row) Use code with caution. 5. Troubleshooting Common Mistakes

You need to iterate 8 times to create each row. Inside this loop, you will determine what values to add based on the row index Apply Logic for Pieces vs. Blanks Pieces (1s) statement to check if the current row index is less than 3 (top) OR greater than 4 (bottom). Blanks (0s) statement for the middle rows. Example Implementation

Ensure the loops are range(8) to create