How to make the square have blue lines and be at the front of the green line?

Question:

I want to make the square appear at the start of the green line and be blue. How do I do that?

from turtle import *
color('green')
begin_fill()

forward(200)
end_fill()

import turtle

turtle.color('blue')

# Creating a for loop that will run four times  
for j in range(4):
    turtle.forward(20)  # Moving the turtle Forward by 150 units
    turtle.left(90)     # Turning the turtle by 90 degrees

As of now the square is not blue and is drawn at the end of the green line.

Asked By: Alaska

||

Answers:

Put the begin_fill/end_fill around the drawing of the square, draw the square first, then the line:

import turtle as t

t.color('blue')

t.begin_fill()
for _ in range(4):
    t.forward(20)
    t.left(90)
t.end_fill()

t.color('green')
t.forward(200)

t.mainloop()

Blue filled square at left end of green line

Answered By: Mark Tolonen