How to exit a program but keep the turtle window open?

I have tried exit() but it doesn't keep the turtle window open

Use Tiny Wizards

I watch you sleep toby dent

If there is an open window, it means that the program is still running. Your question is a contradiction.

What you can do is launch the turtle program from another program which exits immediately. For example here is a turtle program

# progA.py

from turtle import *
angle = 5
distance = 20
compteur = 0

while compteur <= 30:
    forward(distance)
    left(angle)
    compteur += 1
    angle += 2

mainloop()

And here is the program which launches progA.py and exits immediately:

# progB.py

import subprocess as sp
import sys

if __name__ == '__main__':
  python = sys.executable
  process = sp.Popen([python, "progA.py"])
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.