Lists
How to write a list
Name the list and use square brackets, separate the different items out with
commas and add quotation marks before and after each word.
The list can then be called later in the code. For example, numList = [1, 2, 3]
.
A Simple Example
This code works because the loop goes 6 times, and there are 6 colours in the list.
A Better Example
If the list has fewer colours than the number of loops, it would stop before the loop finishes. To fix that, we use the % symbol. This symbol makes the list repeat itself after it reaches the end, so we never run out of colours.
Colours
Here’s a little bit about the colour functions in Turtle:
A Colour Example
In this example we set the background to light blue, then make the turtle draw a circle outline in red. Then circle is filled with yellow inside.
Checklist
- I know what a modulo (%) does.
- I can create a list.
- I can make my turtle draw different colours.
- I can use different functions to set what I’m colouring in.