SignUpLoginPython / createaccount
sunnyujjawal's picture
Create createaccount
4cb0548
# 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.")