Python Turtle Colors: Full Colors List, RGB, Hex and colormode

Python Turtle accepts colours in three forms: a name such as "tomato", a hex code such as "#1e90ff", or an RGB tuple such as (46, 139, 87). Set the line colour with pencolor(), the fill with fillcolor(), both at once with color(), and the window with screen.bgcolor(). Below is the full chart of the 147 colour names, how colormode() works, and examples of random colours, rainbows and gradients.

Every program was run with Python 3.12.5 (Tk 8.6.13) on Windows 11; the screenshots are the real Turtle windows. For the full reference, see turtle.pencolor() in the Python documentation.

Quick answer: pen, fill and background colour

import turtle

screen = turtle.Screen()
screen.setup(560, 400)
screen.bgcolor("lightyellow")          # background colour

t = turtle.Turtle()
t.pensize(6)
t.pencolor("navy")                     # outline colour
t.fillcolor("orange")                  # fill colour

t.penup()
t.goto(0, -100)                        # start at the bottom of the circle
t.pendown()
t.begin_fill()
t.circle(100)
t.end_fill()

t.hideturtle()
turtle.done()
Python Turtle pencolor fillcolor bgcolor example: orange filled circle with a navy outline on a light yellow background
Navy pen, orange fill, light yellow background.
MethodSetsExample
t.pencolor(c)Line and text colourt.pencolor("navy")
t.fillcolor(c)Colour used by begin_fill()/end_fill()t.fillcolor("orange")
t.color(pen, fill)Both at once (one argument sets both)t.color("navy", "orange")
screen.bgcolor(c)Window backgroundscreen.bgcolor("lightyellow")
screen.colormode(255)RGB values 0–255 instead of 0.0–1.0t.pencolor(46, 139, 87)

Three ways to write a colour: name, hex and RGB

import turtle

screen = turtle.Screen()
screen.setup(720, 360)
screen.colormode(255)                  # allow 0-255 RGB values

t = turtle.Turtle()
t.hideturtle()
t.speed(0)
t.pensize(3)

def swatch(x, color, label):
    t.penup()
    t.goto(x, -40)
    t.pendown()
    t.color("black", color)
    t.begin_fill()
    for _ in range(4):
        t.forward(120)
        t.left(90)
    t.end_fill()
    t.penup()
    t.goto(x + 60, -80)
    t.write(label, align="center", font=("Consolas", 12, "normal"))

swatch(-330, "tomato", '"tomato"')             # colour name
swatch(-170, "#1e90ff", '"#1e90ff"')           # hex code
swatch(-10, (46, 139, 87), "(46, 139, 87)")    # RGB tuple (colormode 255)
swatch(150, "#f80", '"#f80"')                  # short hex

turtle.done()
Python Turtle colours written as a name, a hex code, an RGB tuple and a short hex code, shown as four filled squares
The same kind of colour written four ways.

Python Turtle colors list (all 147 names)

Turtle uses Tk’s colour names, which match the standard CSS/web colour names. This chart was drawn by Turtle itself with every name that works, sorted by colour:

Python Turtle colors list chart: all 147 named colours such as red, tomato, orange, gold, green, teal, royalblue, purple and pink with a swatch for each
All 147 CSS colour names that Turtle accepts, drawn with Turtle.

The program that draws the chart (the list of names is shortened here):

import turtle

NAMES = ["black", "dimgray", "gray", "silver", "white", "red", "tomato", "orange", "gold", ...]    # 147 colour names, sorted by hue

screen = turtle.Screen()
screen.setup(1280, 1000)
screen.title("Python Turtle colours")
screen.tracer(0)                       # draw everything at once

t = turtle.Turtle()
t.hideturtle()
t.penup()

COLS, W, H = 6, 205, 30
left, top = -615, 470
for i, name in enumerate(NAMES):
    col, row = i % COLS, i // COLS
    x, y = left + col * W, top - row * (H + 8)
    t.goto(x, y - H)
    t.color("#cccccc", name)
    t.pendown()
    t.begin_fill()
    for side in (40, H, 40, H):
        t.forward(side)
        t.left(90)
    t.end_fill()
    t.penup()
    t.goto(x + 48, y - H + 7)
    t.color("black")
    t.write(name, font=("Arial", 10, "normal"))

screen.update()
turtle.done()
  • Names are not case-sensitive and may contain spaces: "SteelBlue", "steelblue" and "steel blue" are the same.
  • Many names have darker numbered versions: "steelblue1" to "steelblue4" (312 of these work), plus "gray0" (black) to "gray100" (white).
  • One CSS name does not work: "rebeccapurple". Use its hex code "#663399" instead.

You can look up the exact RGB value Turtle will use for any name:

import tkinter as tk

root = tk.Tk()
root.withdraw()

def rgb(name):
    """The RGB value Tk uses for a colour name (Turtle uses the same names)."""
    r, g, b = root.winfo_rgb(name)
    return r // 257, g // 257, b // 257

for name in ["SteelBlue", "steel blue", "steelblue1", "steelblue4", "gray50", "grey90", "#f80"]:
    print(f"{name!r:14} -> {rgb(name)}")

try:
    rgb("rebeccapurple")
except tk.TclError as err:
    print("TclError:", err)

root.destroy()

Output:

'SteelBlue'    -> (70, 130, 180)
'steel blue'   -> (70, 130, 180)
'steelblue1'   -> (99, 184, 255)
'steelblue4'   -> (54, 100, 139)
'gray50'       -> (127, 127, 127)
'grey90'       -> (229, 229, 229)
'#f80'         -> (255, 136, 0)
TclError: unknown color name "rebeccapurple"

colormode(): RGB values 0–1 or 0–255

By default Turtle expects RGB values between 0.0 and 1.0. Passing 0–255 values in that mode is the most common colour error, bad color sequence. Switch with screen.colormode(255):

import turtle

screen = turtle.Screen()
t = turtle.Turtle()

print("default colormode:", screen.colormode())
t.pencolor(0.2, 0.6, 1.0)          # 0.0-1.0 in the default mode
print(t.pencolor())

try:
    t.pencolor(255, 140, 0)        # 0-255 values in colormode 1.0
except turtle.TurtleGraphicsError as err:
    print("TurtleGraphicsError:", err)

screen.colormode(255)
t.pencolor(255, 140, 0)            # now fine
print(t.pencolor())

try:
    t.pencolor("rebeccapurple")
except turtle.TurtleGraphicsError as err:
    print("TurtleGraphicsError:", err)

screen.bye()

Output:

default colormode: 1.0
(0.2, 0.6, 1.0)
TurtleGraphicsError: bad color sequence: (255, 140, 0)
(255.0, 140.0, 0.0)
TurtleGraphicsError: bad color string: rebeccapurple

colormode() changes how Turtle reads and returns RGB colours, so set it once at the start of your program.

Get the current colour

import turtle

t = turtle.Turtle()

t.color("red", "gold")
print(t.color())          # (pen colour, fill colour)
print(t.pencolor(), t.fillcolor())

t.pencolor("#1e90ff")
print(t.pencolor())       # a hex code comes back as an RGB tuple

turtle.Screen().bye()

Output:

('red', 'gold')
red gold
(0.11764705882352941, 0.5647058823529412, 1.0)

Names come back as names, but hex codes come back as an RGB tuple in the current colormode. In colormode 255 the values are floats, for example (255.0, 140.0, 0.0) in the previous example.

Random colours

With colormode(255) a random colour is just three random integers. random.seed() makes the “random” picture the same on every run:

import random
import turtle

screen = turtle.Screen()
screen.setup(600, 480)
screen.bgcolor("black")
screen.colormode(255)
screen.tracer(0)

random.seed(7)                          # same "random" picture every run
t = turtle.Turtle()
t.hideturtle()
t.penup()

for _ in range(60):
    t.goto(random.randint(-260, 260), random.randint(-200, 200))
    t.dot(random.randint(15, 60), (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))

screen.update()
turtle.done()
Python Turtle random colors: 60 dots in random sizes and random RGB colours on a black background
60 dots with random RGB colours.

Rainbow colours with colorsys

To walk through the rainbow, change the hue and convert it to RGB with the standard colorsys module. Its output is in 0.0–1.0, which matches Turtle’s default colormode:

import colorsys
import turtle

screen = turtle.Screen()
screen.setup(600, 600)
screen.bgcolor("black")
screen.tracer(0)

t = turtle.Turtle()
t.hideturtle()
t.pensize(2)

steps = 360
for i in range(steps):
    hue = i / steps                              # 0.0 -> 1.0 goes once round the colour wheel
    t.pencolor(colorsys.hsv_to_rgb(hue, 1, 1))   # (r, g, b) in 0.0-1.0: the default colormode
    t.forward(i * 0.7)
    t.left(59)

screen.update()
turtle.done()
Python Turtle rainbow colors spiral drawn with colorsys.hsv_to_rgb on a black background
A spiral whose colour goes once round the colour wheel.

A colour gradient between two colours

Blend from one RGB colour to another by moving each channel a little at each step:

import turtle

screen = turtle.Screen()
screen.setup(640, 340)
screen.colormode(255)
screen.tracer(0)

t = turtle.Turtle()
t.hideturtle()
t.pensize(6)

start, end = (255, 94, 58), (36, 90, 190)          # orange -> blue
steps = 100
for i in range(steps):
    f = i / (steps - 1)
    color = tuple(round(a + (b - a) * f) for a, b in zip(start, end))
    t.pencolor(color)
    t.penup()
    t.goto(-280 + i * 5.6, -80)
    t.pendown()
    t.goto(-280 + i * 5.6, 80)

screen.update()
turtle.done()
Python Turtle color gradient from orange to blue drawn as 100 vertical lines
100 lines blending orange into blue.

Change colour on click or key press

Bind a function with screen.onclick() or screen.onkey() to change colours while the program runs (more events in the Python Turtle cheat sheet):

import turtle

COLORS = ["red", "orange", "gold", "green", "royalblue", "purple"]

screen = turtle.Screen()
screen.setup(520, 380)

t = turtle.Turtle(shape="turtle")
t.shapesize(4)
t.color("black", COLORS[0])

def next_color(x=None, y=None):
    i = (COLORS.index(t.fillcolor()) + 1) % len(COLORS)
    t.fillcolor(COLORS[i])
    screen.bgcolor("white" if i % 2 else "lightgray")

screen.onclick(next_color)        # click anywhere
screen.onkey(next_color, "space") # or press Space
screen.listen()

turtle.done()
Python Turtle change color on click: a large turtle shape filled green after three clicks
After three clicks: red → orange → gold → green.

Common colour errors

  • TurtleGraphicsError: bad color sequence: you passed 0–255 values while colormode is 1.0. Call screen.colormode(255) or divide the values by 255.
  • TurtleGraphicsError: bad color string: the name is misspelled or unknown (such as "rebeccapurple"). Check it against the chart above or use a hex code.
  • The shape is not filled: fillcolor() alone doesn’t fill; draw the shape between begin_fill() and end_fill().
  • Hex codes need the # and 3 or 6 hex digits: "#f80" or "#ff8800".

Frequently asked questions

How do I change the colour in Python Turtle?

Use t.pencolor("red") for lines, t.fillcolor("red") for fills, or t.color("red", "yellow") for both. The background is turtle.Screen().bgcolor("black").

What colours are available in Python Turtle?

The 147 CSS/web colour names shown in the chart above (except rebeccapurple), their numbered variants such as steelblue1–steelblue4, gray0–gray100, and any hex code or RGB value.

How do I use RGB colours in Turtle?

Either pass values from 0.0 to 1.0, such as t.pencolor(0.2, 0.6, 1.0), or call screen.colormode(255) first and pass 0–255 values.

Why do I get ‘bad color sequence’?

The RGB values don’t match the colormode. In the default mode (1.0) values must be between 0 and 1; call screen.colormode(255) to use 0–255.

How do I make random colours in Turtle?

Call screen.colormode(255) and pass (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)), or pick from a list with random.choice(["red", "gold", "teal"]).

Keep exploring Turtle graphics: