Session 5, #1: Numbers from Lists


We wrote programs to change the turtle's colors using a list. Let's use the same idea, but instead of colors, we will have a list of distances:

Let's step through the program:

  1. We create a turtle for drawing.
  2. For each item in the list,
    1. Move forward the distance num from our list
    2. Turn our turtle to the right 93 degrees

The variable, num, takes each value in the list of the numbers. The first time through the loop num is 123. The next time it is 55. The loop continues until each item in the list is used. We use num to control how many step the turtle, tess, moves forward:

	tess.forward(num)