print ('Password Request Initiative')
password = 'abcd'
user_input = input('Please Enter Password: ')
if user_input != password:
print("Haha. Nope")
quit()
elif user_input == password:
print ("User is now logged in...")
enter code here
that's the code, but when I run it and type the wrong password it shows this warning:And I want it to run without this message so it just instantly closes
To avoid the message when running from IDLE, do not use
quit()
orexit()
in a program. They are not part of the language and are not intended for this use. They are (usually) added by the site package for interactive use only. In particular, they were added so that people could more easily exit the interactive interpreter when running in a terminal window -- without knowing the magic control code needed on a particular system -- and without closing the terminal window itself.On Unix,
^D
, End of File, exits, but on DOS and still on Windows,^Z<Return>
is used instead. Few beginners know this. Other interactive programs usequit
andexit
, so we added those as synonyms.With IDLE,
^D
in the shell closes the shell on all systems, but not editor windows. It is the same as clicking the close button on the title bar. At least on Windows,^Q
==quit()
and closes everything.To exit a program when not as the bottom of a file, use
raise SystemExit
orsys.exit()
.As the expansion of the acronym says, IDLE is a development environment. It is a feature of IDLE that testing a program within IDLE does not kill IDLE itself, at least not without warning.