Why does this error of name 'sys' is not defined?

1

Why does this error occur with name 'sys' is not defined ?

while True :
    print ('Digite exit para sair')
    response = input ()
    if response == 'exit':
        sys.exit()
        print('Você digitou' + response + ',')

/data/data/org.qpython.qpy/files/bin/qpython3-android5.sh "/storage/emulated/0/qpython/exSair.py" && exit
e/emulated/0/qpython/exSair.py" && exit  <
Digite exit para sair
exit
Traceback (most recent call last):
  File "/storage/emulated/0/qpython/exSair.py", line 5, in <module>
    sys.exit()
NameError: name 'sys' is not defined
1|u0_a266@jflte:/ $
    
asked by anonymous 24.06.2018 / 20:41

1 answer

1

The sys module is not set at runtime because it was not imported.

At the top of your code, add:

import sys

import documentation.

    
24.06.2018 / 21:03