Learn to Code via Tutorials on Repl.it!

← Back to all posts
How to make a colorful spiral of turtles with turtle stamp.

# How to make a spiral of turtles

So this is pretty simple, but you'll need to know python basics first.

If you don't know the language check out this website:
https://www.w3schools.com/python/python_intro.asp

Heres a picture of the final result:

# 1.

First create a repl with python with turtle.

Then import the turtle and random modules.

``````import turtle
import random``````

# 2.

Make your turtle a turtle shape.

``turtle.shape('turtle')``

Lift your turtle so it doesn't draw one straight line.

``turtle.penup()``

# 3.

Create a variable for the distance your turtle moves(paces).
Twenty paces is the minimum but you can do more.

``paces = 20``

# 4.

Start a loop to repeat the stamping code.
You can repeat any number of times.

``for i in range(50):``

Assign a random function to a variable called 'random_red' to pick a random red value.
Assign a variable for blue and green as well.

``````random_red = random.randint(0, 225)
random_blue = random.randint(0, 255)
random_green = random.randint(0, 225)``````

# 5.

Set the turtle color as the randomly chosen rgb (red, green, and blue) values.

``turtle.color(random_red, random_blue, and random_green)``

Now stamp your turtle.

``turtle.stamp()``

# 6.

Add more paces
Once again, 3 is the minimum but, you can do more.

``paces += 3``

Move forward by the new number of paces.

``stamp.forward(paces)``

Finally, slightly turn your turtle right as it moves to start spiraling.
Please put the turn as 25, if you put another number it might not become a spiral.

``stamp.right(25)``

# Finish

Thats it, you have made a spiral of turtles.
I hope you enjoyed this, if you have any advice please comment.

Commentshotnewtop
DynamicSquid (4531)

It's a turtle spiral!!

JosephSanthosh (1191)

This is such an in depth tutorial too!

k9chelsea2 (730)

also if you use a # in markdown you need to put a whitespace after the # and before the text if thats what you where trying to achieve

k9chelsea2 (730)

also the `finish` at the end needs a whitespace as well if you where doing the big text thingy