Turtle Pen
The Pen
The turtle draws with a pen.
When the pen is down, the turtle draws a line when it moves. When the pen is up, the turtle moves without drawing.
The pen is down when the turtle is created. That is why the turtle has drawn a line every time it moved so far.
Pen Up and Pen Down
Use penup() to lift the pen, and pendown() to put it down again:
Example
Draw two lines with a gap between them:
import turtle
t = turtle.Turtle()
t.forward(50)
t.penup()
t.forward(50)
t.pendown()
t.forward(50)
turtle.done()
Result:
The turtle moves 150 pixels in total, but it only draws while the pen is down.
You will often lift the pen to move the turtle to a new place before you start drawing. You will learn how in the Turtle Position chapter.
Pen Size
Use pensize() to set how thick the lines are, in pixels:
Example
Draw a thick line:
import turtle
t = turtle.Turtle()
t.pensize(5)
t.forward(100)
turtle.done()
Result:
The default pen size is 1.
You can change the pen size at any time. The new size is used for the lines drawn after the change:
Example
Draw a line that gets thicker:
import turtle
t = turtle.Turtle()
t.pensize(1)
t.forward(50)
t.pensize(5)
t.forward(50)
t.pensize(10)
t.forward(50)
turtle.done()
Result:
Hide the Turtle
Use hideturtle() to hide the turtle, so you only see the drawing:
Example
Hide the turtle when the line is drawn:
import turtle
t = turtle.Turtle()
t.forward(100)
t.hideturtle()
turtle.done()
Result:
Use showturtle() to show the turtle again.
A hidden turtle can still move and draw. You just cannot see it.