I’m taking a Python class at the local Adult Ed. They just had us code a fractal snowflake to teach us recursion. It’s kinda fun, I suppose.
My code is below:
import turtle def koch(t, length, n): if n == 0: return angle = 60 t.fd(length*n) t.lt(angle) koch(t, length, n-1) t.rt(2*angle) koch(t, length, n-1) t.lt(angle) t.fd(length*n) def snowflake(t,length,n): for i in range(6): koch(t, length,n) t.rt(60) myrtel = turtle.Turtle() snowflake(myrtel, 3, 5) turtle.mainloop()
Cool! It worked for me when I added a colon to the end of “for i in range(6)”.
Yes, that must have gotten dropped when I copied it to the blog. I’ve added it so that others can copy the code.
Thanks for catching it.