File size: 1,117 Bytes
4cb0548 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# First, we'll create a dictionary to store the users and their corresponding passwords
users = {}
# Now, we'll define a function to handle signup
def signup():
# Prompt the user to enter a username and password
username = input("Enter a username: ")
password = input("Enter a password: ")
# Add the username and password to the users dictionary
users[username] = password
print("Signup successful!")
# Next, we'll define a function to handle login
def login():
# Prompt the user to enter their username and password
username = input("Enter your username: ")
password = input("Enter your password: ")
# Check if the username and password match a set in the users dictionary
if (username in users) and (users[username] == password):
print("Login successful!")
else:
print("Invalid username or password. Please try again.")
# Now, we'll prompt the user to choose between signup and login
while True:
choice = input("Would you like to signup or login? (s/l) ")
if choice == 's':
signup()
elif choice == 'l':
login()
else:
print("Invalid choice. Please try again.")
|