There is no error but i can't understand why its not working on code playground?
import turtle import time import random score = 0 high_score = 0 delay = 0.15 wn = turtle.Screen() wn.title("Snake") wn.bgcolor("Black") wn.setup(width=600, height=600) wn.tracer(0) head = turtle.Turtle() head.speed(0) head.shape("square") head.color("red") head.penup() head.goto(0, 0) head.direction = "stop" food = turtle.Turtle() food.speed(0) food.shape("circle") food.color("yellow") food.penup() food.goto(0, 100) segments = [] pen = turtle.Turtle() pen.speed(0) pen.shape("square") pen.color("white") pen.penup() pen.hideturtle() pen.goto(0, 260) pen.write("Score: 0, High Score: 0", align="center", font=("Courier", 24, "normal")) def go_up(): if head.direction != "down": head.direction = "up" def go_down(): if head.direction != "up": head.direction = "down" def go_left(): if head.direction != "right": head.direction = "left" def go_right(): if head.direction != "left": head.direction = "right" def move(): if head.direction == "up": y = head.ycor() head.sety(y + 20) if head.direction == "down": y = head.ycor() head.sety(y - 20) if head.direction == "left": x = head.xcor() head.setx(x + 20) if head.direction == "right": x = head.xcor() head.setx(x - 20) wn.listen() wn.onkeypress(go_up, "w") wn.onkeypress(go_down, "s") wn.onkeypress(go_left, "d") wn.onkeypress(go_right, "a") while True: wn.update() if head.xcor() > 290 or head.xcor() < -290 or head.ycor() > 290 or head.ycor() < -290: time.sleep(1) head.goto(0, 0) head.direction = "stop" if head.distance(food) < 20: x = random.randint(-290, 290) y = random.randint(-290, 290) food.goto(x, y) new_segment = turtle.Turtle() new_segment.speed(0) new_segment.shape("square") new_segment.color("grey") new_segment.penup() segments.append(new_segment) sc