185k views
0 votes
A programmer wants to write a program in which the turtle draws 8 squares in a row while moving forward. The final result should look like this:

(8 blocks stacked on top of each other, arrow on top left corner facing up)

But something is wrong! The incorrect code is shown below. The programmer has attempted to write a function to draw a single square. Then he wrote another function that attempts to call that function 8 times.

Mentally trace through the code and determine which line of code should be removed to make the program do what it's supposed to.

1 Answer

3 votes

Final answer:

Remove the line 'for i in range(8):' to fix the program.

Step-by-step explanation:

The incorrect line of code that should be removed to make the program do what it's supposed to is:

for i in range(8):

Because this line of code is causing the function to draw the square 8 times in a row without moving the turtle forward. To fix this, you should remove this line of code and simply call the draw_square() function once.

User Sngreco
by
8.1k points