Shell restarting rather than running code
<p>Trying to draw a straight line using</p>

<pre><code>import turtle

def draw_line():
window =turtle.Screen()
window.bgcolor("blue")

animal=turtle.Turtle ()
animal.forward(100)

window.exitonclick()

draw_line()
</code></pre>

<p>but the shell keeps restarting and doesn't run the code.
Help!</p>

<p>I tried to run your code as follows:</p>

<pre><code>import turtle

def draw_line():
    window = turtle.Screen()
    window.bgcolor('blue')
    animal = turtle.Turtle()
    animal.forward(100)
    window.exitonclick()

draw_line()
</code></pre>

<p>And I can successfully run it.</p>

<p>I saved the above code in a file called <code>turtle_test.py</code> and ran it on the command line like this:</p>

<pre><code>python turtle_test.py
</code></pre>

<p>For me that opens a new window with the expected output and it closes on click.</p>

<p>I tried it with both Python 2.6 and Python 3.5. Neither version had a problem with this script. One thing I have to mention though is that the window created by this script did not get focus automatically. I had to find it by Alt-Tab'ing, maybe that's your problem as well?</p>

<p>Also sorry for answering without a definitive answer, but it seems I need 'points' to be able to post a comment.. </p>

python class