'Pycharm error while running Python Turtle Graphics

I have looked at similar questions but I still can't seem to solve this problem. I am trying to use Python Turtle in Pycharm and it simply won't work. I get the message "Not responding".

It should also be noted that this is an issue solely with Pycharm. I have tried running this code in vs code and in the command prompt and it works on both of them. However, I really like using Pycharm and would like to also use it for this project.

This is my code:

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 solve this issue?



Sources

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

Source: Stack Overflow

Solution Source