make bouncing turtle with python
<p>i am a beginner with python
I wrote this code to make bouncing ball with turtle it works but have some erors like ball dissapering</p>

<pre><code>import turtle
turtle.shape("circle")
xdir = 1
x = 1
y = 1
ydir = 1
while True:
     x = x + 3 * xdir
     y = y + 3 * ydir
    turtle.goto(x , y)
    if x &gt;= turtle.window_width():
        xdir = -1
    if x &lt;= -turtle.window_width():
        xdir = 1
    if y &gt;= turtle.window_height():
        ydir = -1
    if y &lt;= -turtle.window_height():
        ydir = 1
    turtle.penup()
turtle.mainloop()
</code></pre>

<p>You should put
turtle.penup()
Before the while loop to make your code better and a little bit faster. It is almost a bug! </p>

python turtle-graphics