0

I have a function that draws a shape of different colors. My question is how would I pass a list of colors to draw this shape.

def drawCircle(color, radius):
    turtle.color(color)
    turtle.penup()
    turtle.setpos(0, -radius)
    xpos=turtle.xcor()
    ypos=turtle.ycor()
    head=turtle.heading()
    turtle.begin_fill()
    turtle.pendown()
    turtle.home()
    turtle.setpos(xpos,ypos)
    turtle.setheading(head)
    turtle.circle(radius)
    turtle.home()
    turtle.end_fill()
    turtle.penup()

colorList = ["red", "green", "blue", "black"]

drawCircle(colorList, 100)

This function is supposed to go around a circle drawing arcs or the colors:

DamnGood
  • 109
  • 4
  • 13

1 Answers1

0

Well you are passing a list of colors, but looking at your code your expecting 1 color because of turtle.color(color). If you want to access an element of the list you would do color[i] where i is the index of the color you want.

If you want to do something for each color in the list.

for x in colors:
    Do something with x
SJP
  • 1,330
  • 12
  • 21
  • thanks for the input but I have already tried this and not working what I'm trying to accomplish is something similar to [this](http://stackoverflow.com/questions/14095849/calculating-the-analogous-color-with-python) – DamnGood May 02 '14 at 19:48