2
Why does this error occur 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:/ $
It’s not easier to test the case that
response
is not equal to'exit'
and leave withoutsys.exit()
?– Marcelo Shiniti Uchimura
And must have missed the
import sys
at the beginning of the program– Marcelo Shiniti Uchimura
And learn how to format your question in Sopt.
– Marcelo Shiniti Uchimura
Vlw. Thank you, I’m learning and I’m new to the stack.
– Ismael dos Santos Cardoso
This is @Ismaeldossantoscardoso! Welcome to Stack Overflow in English (Sopt). Check out this link: https://answall.com/tour
– vinibrsl