what does bad color sequence mean in python turtle?

derpyherp picture derpyherp · May 27, 2013 · Viewed 16.7k times · Source

I am using python turtle for a project where i need turtle to draw characters. but when i try to use the rgb value foe a color i keep getting an error message. the input is

turtle.color((151,2,1))

followed by a series of movements,however when i run the program i get this message

File "C:/Users/Larry/Desktop/tests.py", line 5, in center
turtle.color((151,2,1))
File "<string>", line 1, in color
File "C:\Python33\lib\turtle.py", line 2208, in color
pcolor = self._colorstr(pcolor)
File "C:\Python33\lib\turtle.py", line 2688, in _colorstr
return self.screen._colorstr(args)
File "C:\Python33\lib\turtle.py", line 1158, in _colorstr
raise TurtleGraphicsError("bad color sequence: %s" % str(color))
turtle.TurtleGraphicsError: bad color sequence: (151, 2, 1)

what does this mean and how can i fix it?

Answer

Petr Viktorin picture Petr Viktorin · May 27, 2013

From the docs:

Each of r, g, and b must be in the range 0..colormode, where colormode is either 1.0 or 255 (see colormode()).

Your colormode is probably set to 1.0, so either the individual color coordinates need to be floats in the range 0 to 1, or you need to set the colormode to 255.