0

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?

António Rebelo
  • 186
  • 1
  • 13
  • How are you running this, exactly? From a terminal? From an IDE? Which operating system? Remember that this needs to get input from the terminal. If you're running it from something that doesn't have a terminal, it's going to appear to be inactive. – Tim Roberts Mar 18 '22 at 21:04
  • @TimRoberts I am using Windows and running it in Pycharm. Is Python turtle something that only works when run in cmd? I haven't tried this btw – António Rebelo Mar 18 '22 at 21:06
  • Do you see the "Enter the number of racers" prompt in the Pycharm terminal window? – Tim Roberts Mar 18 '22 at 21:08
  • @TimRoberts I have now tried to run this file on cmd, which worked. However, when I went back to pycharm and tried to run this code, I got the error: [Errno 2] No such file or directory – António Rebelo Mar 18 '22 at 21:14
  • That seems like a topic for a new question! – Tim Roberts Mar 18 '22 at 21:15
  • @TimRoberts I am not sure why but I now can run my code on pycharm again. However, I still get the error message of the "not responding" when opening python turtle. Do you know how to fix this problem? – António Rebelo Mar 18 '22 at 21:20
  • I don't use Pycharm, so I don't know it's peculiarities. Web tutorials suggest you need to change the Pycharm project settings to use your primary Python interpreter, instead of the one built-in to Pycharm. https://stackoverflow.com/questions/53797598/how-to-install-tkinter-with-pycharm – Tim Roberts Mar 18 '22 at 21:26

0 Answers0