I have this code:
def rollBox(length, numDivisions, count):
Angle = 90/numDivisions
if count == 0:
return
elif numDivisions == 0:
rollBox(length, numDivisions, count - 1)
else:
square(length)
turtle.right(Angle)
rollBox(length, numDivisions - 1, count)

Is there any way to still decrease the 'numDivisions' parameter to zero while still keeping its original value? I don't know if that makes sense, but I don't want the original value to change because I want the turtle to rotate at the same angle each time. I'm getting a divide by zero error.

you could just create a copy of numDivisions at the start of the function then use the copy of numDivisions whenever you want the original value.

I do not quite get what is your purpose. Something like this?

import turtle

def square(length):
    for i in range(4):
        turtle.forward(length)
        turtle.right(90)

def roll_box(length, num_divisions):
    turtle.fill(True)
    turtle.down()
    for count in range(num_divisions):
        angle = 360.0/num_divisions
        square(length)
        turtle.right(angle)

turtle.reset()
turtle.setup(width=1000, height=600, startx=0, starty=0)
roll_box(100,12)
turtle.mainloop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.