Codehs Fixed: 916 Checkerboard V1

We import the turtle module to use graphics.

If the assignment specifically requires while loops (where the bug usually exists), here is the fixed while loop implementation. 916 checkerboard v1 codehs fixed

The Bug: Students often write while count > 0: but forget to write count = count - 1. The Fix: Ensure the counter decrements at the end of the loop. We import the turtle module to use graphics

# WHILE LOOP VERSION (Fixed)
import turtle
t = turtle.Turtle()
t.speed(0)
SIZE = 50
# Starting coordinates
x = -200
y = 200
# Row Counter
row_count = 8
while row_count > 0:
    # Column Counter
    col_count = 8
# Reset X for new row
    x = -200
while col_count > 0:
        # Draw Logic (simplified)
        t.penup()
        t.goto(x, y)
        t.pendown()
        t.begin_fill()
        # Draw square helper logic
        for i in range(4):
            t.forward(SIZE)
            t.left(90)
        t.end_fill()
x += SIZE
        # FIX: Decrement col_count
        col_count -= 1
y -= SIZE
    # FIX: Decrement row_count
    row_count -= 1

Create a 8x8 checkerboard using a loop. The checkerboard should have alternating black and white squares. Create a 8x8 checkerboard using a loop

Example structure (not exact solution):

var SQUARE_SIZE = 50;
for(var row = 0; row < 8; row++) 
    for(var col = 0; col < 8; col++) 
        var x = col * SQUARE_SIZE;
        var y = row * SQUARE_SIZE;
        var color = (row + col) % 2 === 0 ? "red" : "black";
        var rect = new Rectangle(SQUARE_SIZE, SQUARE_SIZE);
        rect.setPosition(x, y);
        rect.setColor(color);
        add(rect);