NameError: name 'exit' is not defined

while gui.running:
    if gui.get_event() and gui.is_pressed(gui.SPACE):
        solar.initialize_particles()  # reinitialize when space bar pressed.
    elif gui.is_pressed(gui.ESCAPE):
        exit(0)

NameError: name ‘exit’ is not defined
why can’t use exit to quit ?

Welcome to Taichi community @shuaiyang.

Normally, you could set gui.running = False to break the while loop instead of using exit.

while gui.running:
    if gui.get_event() and gui.is_pressed(gui.SPACE):
        solar.initialize_particles()  # reinitialize when space bar pressed.
    elif gui.is_pressed(gui.ESCAPE):
        gui.running = False

Got that
thank you

1 Like