title: How to draw a tiled triangle with python turtle
body: <p>I am trying to draw a tiled equilateral triangle that looks like this</p>
  
  <p><a href="https://i.stack.imgur.com/X7ybH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X7ybH.png" alt="enter image description here"></a></p>
  
  <p>using python's turtle. I would like to be able to have either 16,25,36,49 or 64 triangles.</p>
  
  <p>My initial attempts are clumsy because I havent figured out how to neatly move the turtle from one triangle to the next.</p>
  
  <p>Here it is my (partially correct) code</p>
  
  <pre><code>def draw_triangle(this_turtle, size,flip):    
      """Draw a triangle by drawing a line and turning through 120 degrees 3 times"""
      this_turtle.pendown()
      this_turtle.fill(True)
      for _ in range(3):
          if flip:
             this_turtle.left(120)
          this_turtle.forward(size)
          if not flip:
             this_turtle.right(120)
      this_turtle.penup()
  
  myturtle.goto(250,0)
  for i in range(4):
     for j in range(4):
        draw_triangle(myturtle, square_size,(j%2 ==0))
        # move to start of next triangle
        myturtle.left(120)
        #myturtle.forward(square_size)
  
     myturtle.goto(-250,(i+1)*square_size)
  </code></pre>
  
  <p>There must be an elegant way of doing this?</p>