QUESTION IMAGE
Question
5 black and white squares
main.py
1
2
3 for i in range (7):
4 if i % 2 = 0:
5 set_fill_color(\black\)
6 else:
7 set_fill_color(\black\)
8 draw_square()
9 move_forward(i)
submit + continue save
output test cases docs assignments goal
run clear check code
parseerror: bad input on line 4
Step1: Identify the error type
The error is a ParseError on line 4, which suggests a syntax issue.
Step2: Check line 4 syntax
In Python, the equality comparison is ==, not =. The line if i % 2 = 0: uses assignment (=) instead of comparison (==). Correcting it to if i % 2 == 0: will fix the syntax error. Also, check indentation: the set_fill_color("black") under the if should be indented, and the draw_square() and move_forward() should be properly structured (maybe the move_forward(i) is intended to be after drawing, and the else block's set_fill_color and draw_square need proper indentation too). But the main syntax error here is the = in the if condition.
Step3: Correct the code
Change line 4 from if i % 2 = 0: to if i % 2 == 0:, and ensure proper indentation for the code blocks (e.g., the set_fill_color under if should be indented, and the else block's statements are indented correctly). Also, the move_forward(i) might be intended to be outside the else or after drawing, but the primary fix here is the == operator.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
The error is a syntax error in line 4: use == (comparison) instead of = (assignment) in the if condition. Correct line 4 to if i % 2 == 0: and fix indentation as needed (e.g., indent set_fill_color("black") under if and structure the else block's code with proper indentation).