Nov-01-2023, 03:11 PM
This loop draws 1 line.
for i in range(n): turtle.pen(fillcolor = "blue", pencolor = "black", pensize = 3) # Place in front of loop. turtle.forward(length) turtle.up() turtle.right(90) turtle.forward(20) turtle.left(90) turtle.down() turtle.up() # <- Pen is up when second iteration of loop runsI would start by changing the code to this:
import turtle def lines(n, length): turtle.pen(fillcolor="blue", pencolor="black", pensize=3) turtle.begin_fill() for i in range(n): turtle.forward(length) turtle.up() turtle.right(90) turtle.forward(20) turtle.left(90) turtle.down() turtle.end_fill() def columns(n, length): turtle.pen(fillcolor="green", pencolor="black", pensize=3) turtle.begin_fill() for i in range(n): turtle.right(90) turtle.forward(length) turtle.up() turtle.left(90) turtle.forward(20) turtle.right(90) turtle.down() turtle.end_fill() lines(3, 32) columns(5, 7) turtle.done()Now you can at least see the turtle errors.