Join 36000+ teachers and students using TTIO.
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.
Code to try yourself (in the trinket below)
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