turtle.color() method in Python (original) (raw)

Last Updated : 15 Jul, 2025

**turtle.color() method is a function of the turtle module in Python used to change the color of the turtle’s pen and fill. It allows us to customize the appearance of shapes drawn by the turtle by specifying colors using color names, RGB values, or hex codes.

Syntax

turtle.color(*args)

The *args allows the method to accept different combinations of arguments, such as a single color string, a tuple of RGB values, or separate RGB values.

**Parameters:

**Return Value: The color() method does not return a value. It modifies the color properties of the turtle object.

Examples of turtle.color() method

1. Dynamic Color Change with turtle.color()

In this code, we will use the turtle module in Python to move the turtle forward and change its color. Initially, the turtle moves in the default color (black), then the color is changed to red, and the turtle moves again in red.

Python `

import turtle

use forward by 50 (default = black)

turtle.forward(50)

change the color of turtle

turtle.color("red")

use forward by 50 (color = red)

turtle.forward(50)

`

**Output

turtleArrow

turtleArrow

**Explanation:

2. Drawing a Colored Square with turtle.color()

In this code, we will use the turtle module to move the turtle and change its color dynamically. The turtle moves forward in different colors (red, blue, green) while turning by 90 degrees after each move, creating a square with different colored sides.

Python `

import turtle

turtle.forward(100)

turtle.color("red")

use forward by 100 in 90 degrees right (color = red)

turtle.right(90) turtle.forward(100)

change the color of turtle

turtle.color((41,41,253))

use forward by 100 in 90 degrees right (color = blue)

turtle.right(90) turtle.forward(100)

change the color of turtle

turtle.color(41,253,41)

use forward by 100 in 90 degrees right (color = green)

turtle.right(90) turtle.forward(100)

`

**Output :

**Explanation: