'Python Turtle not responding

I am fairly new to Python and I have just tried to use Python Turtle. I am following a tutorial on youtube and when I try to open Python Turtle, it says "Not responding" and it doesn't open the page. My mouse has the loading symbol and it then just gives me the not responding message.

This is the code I have written so far:

import turtle

WIDTH, HEIGHT = 500, 500

screen = turtle.Screen()
screen.setup(WIDTH, HEIGHT)
screen.title("Turtle Racing")

def get_number_of_turtles():
    num_turtles = 0
    while True:
        num_turtles = input("Enter the number of racers (2-10): ")
        if num_turtles.isdigit():
            num_turtles = int(num_turtles)
        else:
            print("Invalid input.")
            continue

        if 2 <= num_turtles <= 10:
            return num_turtles
        else:
            print("Number not in range 2-10.")

get_number_of_turtles()

Does anyone know how to fix this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source