Please help!
I need to write a programe, that would draw a picture like this:
http://yfrog.com/6ptreelj
I've tried with recoursion but it doesn't work properly.

from turtle import *

tree(n, lenght):
     if n == 0:
          lt(90)
          fd(lenght)
          rt(45)
          fd(lenght/2)
          bk(lenght/2)
          lt(90)
          fd(lenght/2)
          bk(lenght/2)
          rt(45)
     else:
          rt(135)
          tree(n-1, lenght/2)

I managed to do it by myself :)

Post your code please ;)

from turtle import *
def drevo(n, dolzina, zelva):
    if n == 0:
        zelva.lt(90)
        zelva.fd(dolzina)
        zelva.rt(33)
        zelva.fd(dolzina*(2/3))
        zelva.bk(dolzina*(2/3))
        zelva.lt(66)
        zelva.fd(dolzina*(2/3))
        zelva.bk(dolzina*(2/3))
        zelva.rt(33)
    else:
        drevo(0, dolzina, zelva)
        zelva.rt(123)
        drevo(n-1, dolzina*(2/3), zelva)
        zelva.bk(dolzina*(2/3))
        zelva.rt(24)
        drevo(n-1, dolzina*(2/3), zelva)
        zelva.bk(dolzina*(2/3))
        zelva.rt(33)

Words are in Slovenian language, cause I'm from Slovenia. Drevo means tree, dolzina means lenght, zelva means turtle. :)

commented: nice +4
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.