title: Why isn't the turtle moving?
body: <p>I was coding a turtle game where when the snake goes near the &quot;apple&quot;, it goes to a random cord and we repeat. I tried to add a go to function in python but it is not moving for some reason. I added a check to see if the if statement is happening and it is, but after the check, nothing runs. What is the problem with my code?</p>
  <pre><code>import turtle as t
  
  
  import random
  
  wn=t.Screen()
  
  
  t.shape(&quot;turtle&quot;)
  t.pu()
  
  apple=t.Turtle()
  
  apple.pu()
  
  apple.shape(&quot;circle&quot;)
  apple.color(&quot;red&quot;)
  
  def forw():
    t.forward(10)
  def back():
    t.backward(10)
  
  
  wn.onkey(forw,&quot;Up&quot;)
  wn.onkey(back,&quot;Down&quot;)
  wn.onkey(lambda: t.left(45),&quot;Left&quot;)
  wn.onkey(lambda: t.right(45),&quot;Right&quot;)
  wn.listen()
  
  if t.distance(apple)&lt;=15 or t.distance(apple)&gt;=-15:
    print(&quot;check1&quot;)
    apple.goto(random.randint(-50,50),random.randint(-50,50))
  </code></pre>