I don't know if this is entirely recusion related but i added a small function within my main function to block non-integer inputs with
def main(depth, size):
depth = eval(input("Enter depth that is an integer: "))
if (isinstance( depth, int)) == False:
print( 'Not an integer' )
main(depth, size)
else:
pass
turtle.left(120)
turtle.speed(100)
triangle(depth, size)
def triangle(depth, size):
if depth == 0:
pass
else:
turtle.forward(size)
triangle(depth-1, size/2)
turtle.right(120)
turtle.forward(size)
turtle.left(120)
triangle(depth-1, size/2)
turtle.right(120)
turtle.right(120)
turtle.forward(size)
turtle.right(120)
main(depth, 100)
when I input an integer the program runs fine, when I input a non-int, it returns and tells me it's not an integer and returns to the input stage. then when i put in an integer, it starts drawing the picture as it should, then goes a little bit further, gets hung up at a recurson on line 27 with "triangle(depth-1, size/2)".
I'm so close to finishing this program, I just need to make it harder to crash.