Aug-01-2017, 07:00 PM
(This post was last modified: Aug-01-2017, 07:01 PM by Contraversia.)
So I'm building a miniature code just to simulate a terminal like the command line, how ever it has a log on a phase which requires a password, which is 123 in the example below. I want the command Log off to send it back to the stage where it requires a password but I don't know how. If you could help it would be appreciated.
import time import sys Input = 0 working = 1 Password = 0 Name = "User" Goodbye = "Goodbye" Change_Name = 0 Required_Password = "123" B = "/:" Change_Password = 0 stage = 0 while working == 1: if stage == 0: print("Greetings User") Password = input("Please enter passcode: ") if Password == Required_Password: print("Password excepted") stage = 1 else: raise SystemExit("Password Check failed") C = Name + B if stage == 1: Input = input(C) if Input == "Admin": Change_Password = input("Change Password: ") if Change_Password == Required_Password: print("Sorry, ",Name,", This is the same password") else: Required_Password = Change_Password print("Password changed") if Input == "Show password": print(Password) if Input == ("Help"): print(""" Admin - Allows you to change the password Name - Allows you to change your Name Show password - Shows the password Help - Shows this screen Shut down - Shuts down the system""") if Input == ("Shut down"): raise SystemExit(Goodbye,Name) if Input == ("Name"): Change_Name = input("Change Name: ") if Change_Name == Name: print("Sorry,",Name,",this is the same name.") else: Name = Change_Name print("Name Changed") C = Name + B if input == ("Log out"): stage = 0