Sep-26-2017, 07:31 AM
I'm drawing a polygon in which every side of that polygon should get a random color, that means that for every side the turtle should get a different color, this is my code:
import turtle import random r = 0.0 def cpolygon(n, size, colors): angle = 360/n r = random.randint(25, 160) for i in range(n): turtle.pencolor(str(r)) turtle.forward(100) turtle.left(angle) turtle.mainloop() cpolygon(8, 100, r)And this is the error:
Error:turtle.TurtleGraphicsError: bad color string: 98
Help?