1. To trial the platform and take tests, please take a few seconds to SIGN UP
and SET UP FREE.
2. Searching for something specific? See our text overview of all tests. Includes 'real teacher' use videos.
In order to draw a square, we need to do the same thing four times — we need to repeat the instruction to move the turtle forward some distance and turn 90 degrees. The for statement will repeat the forward and left four times, one time for each value in the list.
import turtle
wn = turtle.Screen()
alex = turtle.Turtle()
for i in [0, 1, 2, 3]: # repeat four times
alex.forward(50)
alex.left(90)
wn.exitonclick()
www.teachyourselfpython.com