NameError: name 'exit' is not defined NameError: name 'exit' is not defined python python

NameError: name 'exit' is not defined


Importing sys will not be enough to make exit live in the global scope.

You either need to do

from sys import exitexit()

or

import syssys.exit()

Note that, as you are also using argv, in the first case you should do from sys import argv,exit


You have to apply the function to sys:

from sys import exitexit()

because exit is the function itself, you need to call it with ()