Drawing a fractal tree in Python, not sure how to proceed
<p>I have this so far in python </p>

<pre><code>import turtle
import math
t = turtle.Turtle()
t.shape("turtle")
t.lt(90)

lv = 11
l  = 100
s  = 17

t.penup()
t.bk(l)
t.pendown()
t.fd(l)

def draw_tree(l, level):
    l = 3.0/4.0*l
    t.lt(s)
    t.fd(l)
    level +=1
    if level&lt;lv:
        draw_tree(l, level)

    t.bk(l)
    t.rt(2*s)
    t.fd(l)
    if level&lt;=lv:
        draw_tree(l, level)
    t.bk(l)
    t.lt(s)
    level -=1

t.speed(100)        
draw_tree(l, 2)
</code></pre>

<p>But I'm kind of stuck on how to proges, because I need to reach for building this tree. This is what I'm trying to produce:</p>

<p><a href="http://i.stack.imgur.com/6w23I.png" rel="nofollow"><img src="http://i.stack.imgur.com/6w23I.png" alt="Fractal tree"></a></p>

<p>Can any one tell me what I am doing wrong?</p>

<p>Your code is basically correct, you mostly need to adjust your parameters.  The example tree you're trying to match is larger than what you are drawing (likely reduced in that image) so increase your <code>l</code> parameter.  The example tree has a couple more levels of recursion than yours so increase your <code>lv</code> parameter.</p>

<p>Finally, you need to reset the pen width based on the recursion level (and unset it on your way out.)  The following rework of your code does this but needs further fine tuning:</p>

<pre><code>import turtle

t = turtle.Turtle(shape="turtle")

t.lt(90)

lv = 13
l = 120
s = 17

t.width(lv)

t.penup()
t.bk(l)
t.pendown()
t.fd(l)

def draw_tree(l, level):
    width = t.width()  # save the current pen width

    t.width(width * 3.0 / 4.0)  # narrow the pen width

    l = 3.0 / 4.0 * l

    t.lt(s)
    t.fd(l)

    if level &lt; lv:
        draw_tree(l, level + 1)
    t.bk(l)
    t.rt(2 * s)
    t.fd(l)

    if level &lt; lv:
        draw_tree(l, level + 1)
    t.bk(l)
    t.lt(s)

    t.width(width)  # restore the previous pen width

t.speed("fastest")

draw_tree(l, 2)

turtle.done()
</code></pre>

python turtle-graphics fractals