I tried running the code that uses the Turtle library on this site, shown here,
import turtle
import random
def main():
tList = []
head = 0
numTurtles = 10
wn = turtle.Screen()
wn.setup(500,500)
for i in range(numTurtles):
nt = turtle.Turtle() # Make a new turtle, initialize values
nt.setheading(head)
nt.pensize(2)
nt.color(random.randrange(256),random.randrange(256),random.randrange(256))
nt.speed(10)
wn.tracer(30,0)
tList.append(nt) # Add the new turtle to the list
head = head + 360/numTurtles
for i in range(100):
moveTurtles(tList,15,i)
w = tList[0]
w.up()
w.goto(0,40)
w.write("How to Think Like a ",True,"center","40pt Bold")
w.goto(0,-35)
w.write("Computer Scientist",True,"center","40pt Bold")
def moveTurtles(turtleList,dist,angle):
for turtle in turtleList: # Make every turtle on the list do the same actions.
turtle.forward(dist)
turtle.right(angle)
main()
in my own Python editor and I got this error:
turtle.TurtleGraphicsError: bad color sequence: (236, 197, 141)
Then, based on this answer on another site, I added in this line before "nt.color(......)"
nt.colormode(255)
Now it's showing me this error
AttributeError: 'Turtle' object has no attribute 'colormode'
Okay, so I checked my Python library and looked into the contents of Turtle.py. The colormode() attribute is definitely there. What is making the code able to run on the original site but not on my own computer?