How do I move this, and make a square a proper position.
import turtle
def draw_square():
window = turtle.Screen()
window.bgcolor("red")
brad = turtle.Turtle()
brad.shape("turtle")
brad.color("yellow")
brad.speed(2)
brad.forward(100)
brad.right(90)
window.exitonclick()
draw_square()
At the moment it does this:
1
I’m not sure exactly what your question is, but if you want to draw a square instead of just a line, then you have to use a for loop to repeat the drawing part four times. (If your question was something different, please edit it to make it clearer.)
Also, there is no need to call your turtle “brad” (t
is conventional).
import turtle
def draw_square():
window = turtle.Screen()
window.bgcolor("red")
t = turtle.Turtle()
t.shape("turtle")
t.color("yellow")
t.speed(2)
for i in range(4):
t.forward(100)
t.right(90)
window.exitonclick()
draw_square()
Output (zoomed in):
I hope this helps.
2