I am making an account code in python and it works but it is really long and I want to know if there is a way to shorten it. Here is my code:
user1 = "Jeff"
user2 = "Bob"
password1 = "Password"
password2 = "Lol"
username = input("Login: >> ")
password = input("Password: >> ")
if username == user1:
if password == password1:
print ("Access granted")
print ("Welcome to the system!")
home()
else:
print ("Access denied")
print ("Try again!")
print ("\n")
time.sleep(2)
login()
elif username == user2:
if password == password2:
print ("Access granted")
print ("Welcome to the system!")
home()
else:
print ("Access denied")
print ("Try again!")
print ("\n")
time.sleep(2)
login()
else:
print ("Access denied")
print ("Try again!")
print ("\n")
time.sleep(2)
login()
The more accounts I create the longer longer it will get. Is there a way to shorten or simplify this?