Of course! The turtle.shape() function in Python's turtle module is used to change the appearance of the "turtle" (the cursor that draws on the screen).

Here's a complete guide, from the basics to more advanced custom shapes.
Basic Usage: Setting a Pre-defined Shape
The turtle module comes with a few built-in shapes. You can switch between them using turtle.shape().
The available built-in shapes are:
"arrow"(the default)"turtle""circle""square""triangle""classic"(a small, symmetrical triangle)
Example: Cycling Through Shapes
This code will draw a square with each side using a different turtle shape.

import turtle
# Get the default turtle object
t = turtle.Turtle()
# List of available shapes
shapes = ["arrow", "turtle", "circle", "square", "triangle", "classic"]
for shape in shapes:
# Change the shape for the next side of the square
t.shape(shape)
# Move forward to draw one side
t.forward(100)
# Turn 90 degrees to the right
t.right(90)
# Keep the window open until you close it
turtle.done()
The resizemode
The shape's appearance can also be affected by the turtle's resizemode. This mode controls how the turtle scales when you change its shapesize.
The three resizemodes are:
"auto"(default): The turtle's shape is stretched to fit the newshapesize."user": The shape is not stretched. Theshapesizevalues only affect the turtle's outline."noresize": The shape is completely unaffected byshapesize.
Example: Comparing Resizemodes
import turtle
# --- Setup the screen and two turtles ---
screen = turtle.Screen()
screen.title("Resizemode Comparison")
# First turtle
t1 = turtle.Turtle()
t1.penup()
t1.goto(-150, 0)
t1.shape("turtle")
t1.color("blue")
t1.write("Resizemode: 'auto'", align="center", font=("Arial", 12, "normal"))
# Second turtle
t2 = turtle.Turtle()
t2.penup()
t2.goto(150, 0)
t2.shape("turtle")
t2.color("red")
t2.write("Resizemode: 'user'", align="center", font=("Arial", 12, "normal"))
# --- Set the resizemodes ---
t1.resizemode("auto")
t2.resizemode("user")
# --- Change the size to see the difference ---
print("Changing size...")
t1.shapesize(5, 2) # Makes it 5 times longer and 2 times taller
t2.shapesize(5, 2)
turtle.done()
When you run this, you'll see the blue turtle stretches, while the red turtle gets a thicker outline but its body shape remains a perfect turtle.
Creating Custom Shapes (Advanced)
This is one of the most powerful features. You can define your own shapes by providing a list of (x, y) coordinates that form the polygon.

The process is:
- Define the coordinates for your shape.
- Register the shape using
screen.register_shape(). - Set the turtle's shape to your new shape name.
Example: Creating a Star Shape
import turtle
# Setup the screen
screen = turtle.Screen()
screen.title("Custom Star Shape")
# Define the coordinates for a 5-pointed star
# The coordinates are relative to the center (0, 0)
star_coords = [
(0, 100), # Top point
(30, 30), # Upper right
(95, 30), # Far right
(50, -10), # Inner right
(65, -80), # Bottom right
(0, -50), # Bottom point
(-65, -80), # Bottom left
(-50, -10), # Inner left
(-95, 30), # Far left
(-30, 30) # Upper left
]
# Register the new shape with the screen
# The first argument is the name you'll use to refer to it
screen.register_shape("my_star", star_coords)
# Create a turtle and set its shape to our custom one
my_turtle = turtle.Turtle()
my_turtle.shape("my_star")
my_turtle.color("gold")
# Animate the star
my_turtle.right(72) # Turn to make it look nicer
my_turtle.forward(150)
turtle.done()
Using Image Files as Shapes
You can also use any .gif image file as a turtle shape. The image should have a transparent background.
Example: Loading an Image
Let's assume you have an image file named my_image.gif in the same directory as your Python script.
import turtle
# Setup the screen
screen = turtle.Screen()
screen.title("Image as a Shape")
# IMPORTANT: Replace "my_image.gif" with the actual path to your image file
# If the image is in the same folder, just the filename is enough.
try:
screen.register_shape("my_image.gif")
except turtle.Terminator:
print("Error: Could not find 'my_image.gif'. Make sure it's in the same folder.")
exit()
# Create a turtle and set its shape
image_turtle = turtle.Turtle()
image_turtle.shape("my_image.gif")
# Move it around
image_turtle.forward(100)
turtle.done()
Summary of Key Functions
| Function | Description | Example |
|---|---|---|
turtle.shape(name) |
Sets the turtle's shape to a pre-defined or custom shape. | t.shape("turtle") |
screen.register_shape(name, coords) |
Registers a new polygonal shape or loads an image. | screen.register_shape("star", coords) |
turtle.resizemode(mode) |
Sets how the turtle scales with shapesize(). |
t.resizemode("user") |
turtle.shapesize(stretch_wid, stretch_len, outline) |
Stretches the turtle in width and length. | t.shapesize(2, 3) |
