Im new to python And i cant figure out how to put a password on my "COMPUTER" code ILL put the code for you to observe

Viewed 28
password = input("Welcome To Computer Put In Your Password.")
if password == "12345":
    print("Welcome,Caden")
else:
    print("Wrong Password")

I want it to be able to stop the code after it says wrong password

2 Answers

quit() is what you're looking for.

password = input("Welcome To Computer Put In Your Password.")
if password == "12345":
    print("Welcome,Caden")
else:
    print("Wrong Password")
    quit()

Change:

print("Wrong Password")

to

raise SystemExit("Wrong Password")
Related