Python Random Color Generation using Turtle -
i need generate random color using r g b values fill in these rectangles python school assignment, i'm getting bad color sequence error though i'm sure i'm formatting python documentation suggests.
r = random.randrange(0, 257, 10) g = random.randrange(0, 257, 10) b = random.randrange(0, 257, 10) def drawrectangle(t, w, h): t.setx(random.randrange(-300, 300)) t.sety(random.randrange(-250, 250)) t.color(r, g, b) t.begin_fill() in range(2): t.forward(w) t.right(90) t.forward(h) t.right(90) t.end_fill() t.penup()
i'm quite confused why t.color(r, g, b) not producing random color?
turtle.colormode needs set 255 give color strings in hex code or r g b.
adding
screen.colormode(255)
no longer returned error.