(If your puzzle differs, the method below still applies; adapt numbers and constraints accordingly.)
win = GraphWin("Checkerboard", 400, 400) draw_checkerboard(win, 8, 8, 50, "black", "white", True) 9.1.7 checkerboard v2 answers
: The core feature of a checkerboard is that adjacent cells differ. Mathematically, you can determine which number to place by checking if the sum of the current indices is even or odd. (row + col) % 2 == 1 Otherwise, place a Row Construction : In each iteration of the outer loop, a current_row list is filled by the inner loop and then appended to : Finally, loop through (If your puzzle differs, the method below still
For additional practice or related exercises, you can view the Intro to Computer Science in Python 3 curriculum on CodeHS. : The print_board function takes the list of
: The print_board function takes the list of lists and converts each integer to a string, joining them with spaces for a clean visual output.
"Right," Maya said. "So, for every row, column 0 is black, column 1 is white. That works for Row 0. But what happens when you jump down to Row 1?"
s representing a checkerboard pattern. To solve this, you need to use and a conditional statement to decide whether to print a