Preview lessons, content and tests

Computer Science & Programming solved. All in one platform.

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.

Repeating with Loops and Lists

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



Additional Video