I want a password thing but if I put a different password it should be a whole differ "USER"

Viewed 26
#Pasword Entry

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

I want it to where I can put all of the same code except it says That and the other person has a different password

password = input("Welcome To Computer Put In Your Password.")
    if password == "sister":
    print("Welcome, sister")

it will be my sister's name But I'm not going to say what it is.

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





password = input("Welcome To Computer Put In Your Password.")
if password == "Sisters password goes here":
    print("Welcome,Sister")
else:
    print("Wrong Password")
    raise SystemExit("Wrong Password")

**I have Code here a calculator a notebook some books a bank and a pizza delivery serves not an actual bank or pizza delivery but...

1 Answers

What platform are you using? You speak of different users--does the other user exist? If you are a linux box, and you login, the login takes care of the context of which user it references. Similarly under Windows. Your code snippet is seriously hackable, and insecure. One would almost ask, why bother have a password at all?

Nonetheless, if you don't want the password to be the same, add another if statement layer, or create an array with the username-password pairs, or write the password out into a separate file in the users home directory. All very very insecure because storing passwords in plain text is always insecure. On linux there are utilites to encrypt and decrypt passwords for the /etc/passwd file.

But here is the first solution pseudocode:

password = input("Welcome To Computer Put In Your Password.")
if user=="Caden":
{  if password == "35805":
      print("Welcome,Caden")
}
else:
if user=="Sister":
{   if password == "name":
        print("Welcome, Sister")
}
else:
{
    print("Wrong Password")
    raise SystemExit("Wrong Password")
}
Related