Search code examples
pythonvisual-studio-codepycharmidemodule-packaging

Why is there a problem with Turtle module?


My turtle module does not work in IDE. Can anyone help me?

Code:

import turtle
t = turtle.pen()

I wrote this code to make the turtle module open its app, but it didn't happen.


Solution

  • You have to add turtle.mainloop() or turtle.done() at the last of the file.

    Starts event loop - calling Tkinter’s mainloop function. Must be the last statement in a turtle graphics program. Must not be used if a script is run from within IDLE in -n mode (No subprocess) - for interactive use of turtle graphics.

    You can read turtle document for more details.