+ 1

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

24th Oct 2019, 4:03 PM
Shahzaib Tayyab
Shahzaib Tayyab - avatar
2 odpowiedzi
+ 9
Sololearn's code playground for languages besides HTML, CSS, and JavaScript are all console based so can't run programs which create GUIs, so you can't run Turtle on the SL playground for Python
24th Oct 2019, 4:05 PM
Faisal
Faisal - avatar
+ 4
A lot of things don't work on Sololearn, turtle is one of them.
24th Oct 2019, 4:05 PM
HonFu
HonFu - avatar