pythonturtle-graphicsspiral

How to have Python turtle make an arithmetic spiral?


I am new to Turtle but my general plan to make the spiral is to define a recursive function archSpiral(initialLen, increment, angle, n) where it does the following sequence n times:

  1. Draw a line segment of initialLen
  2. Turn by angle degrees
  3. And increment the initialLen with increment

By repeating this sequence over and over it should be able to create a spiral.

However I'm having trouble putting this process into text and so far I have

def archSpiral(initialLen, increment, angle, n):
    for _ in range(n):
        turtle.forward(initialLen)
        turtle.left(angle)
        turtle.foward(initialLen + increment)

But it's not working and I'm stuck here.


Solution

  • Just reiterating what Doyousketch2 said:

    def archSpiral(initialLen, increment, angle, n):
        for _ in range(n):
            turtle.forward(initialLen)
            turtle.left(angle)
            initialLen += increment