Checkerboard V1 Codehs — 9.1.6
This pattern creates a perfect checkerboard.
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 9.1.6 checkerboard v1 codehs
Check that your loop runs exactly 8 times. If it goes to 10, the circles will disappear off the right side. This pattern creates a perfect checkerboard
# Check if the row is in the top 3 (index 0,1,2) OR bottom 3 (index 5,6,7) if row < 3 or row > 4: # Fill the entire row with 1s for col in range(8): current_row.append(1) else: # Fill the entire row with 0s (for middle rows 3 and 4) for col in range(8): current_row.append(0) Blanks Pieces (1s) statement to check if the
: Use a loop to append three rows, each containing eight 1s. Fill the Middle Rows : Append two rows of eight 0s. Fill the Bottom Rows : Append another three rows of eight 1s. Function Call : Pass the completed list to the print_board Common Implementation Strategies Simple Append board.append([1] * 8)
As you're working through this problem, here are a few common mistakes to watch out for:
⚠️ Some CodeHS courses include a related exercise, "1.17.6: Checkerboard Karel," which involves using Karel the Dog to paint a checkerboard pattern by moving and placing beepers. However, the 9.1.6 exercise is specifically about creating a 2D list data structure in Python.
Game Perang