Skip to content
Related Articles

Related Articles

Python – turtle.done()
  • Last Updated : 18 Aug, 2020

The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.

turtle.done()

This function is used to starts event loop – calling Tkinter’s main loop function. It does not require any argument. 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.

Syntax : turtle.done()
Parameters : None
Returns : None

Below is the implementation of the above method with some examples :

Example 1 : At the end.






# import package
import turtle
  
# motion
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
  
# stop excution
turtle.done()

Output :

Example 2 : Stop the execution at any step.




# import package
import turtle
  
# motion
turtle.circle(20)
turtle.circle(30)
  
# stop execution
turtle.done()
  
# motion
turtle.circle(40)
turtle.circle(50)

Output :

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :