title: Python making turtle graphic by using list colors
body: <p>I'm trying to make squares with change color each time when I click. but when I run this, it only fills out red color. How can I change color each times?</p>
  
  <pre><code>import turtle
  t= turtle.Turtle()
  s=turtle.Screen()
  colors = ["red","orange","yellow","green","blue","indigo","purple"]
  n=0
  
  def square(x,y):
      t.penup()
      t.goto(x,y)
      t.pendown()
      t.color(colors[n])
      t.begin_fill()   
      for i in range(4):
          t.fd(90)
          t.lt(90)
      t.end_fill()
      t.penup()
  if s.onscreenclick(square) == True:
      n+=1
  </code></pre>