python does not recognize "quit()"

68 Views Asked by At

I've started python in a DOS window. it displays "Python 3.12.0".... But if I input "quit()", I got the message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'quit' is not defined

Now I cannot quit python. Why?

1

There are 1 best solutions below

4
TheHungryCub On

In Python, you can exit the interpreter by typing either exit() or pressing Ctrl + Z followed by Enter (on Windows).

Try using exit() instead of quit() to exit the Python interpreter in the DOS window.

you can use exit(0) to exit the Python interpreter as well.