import sqlite3 # First, we'll create a connection to the database conn = sqlite3.connect("users.db") cursor = conn.cursor() # Now, we'll create a table to store the users and their corresponding passwords cursor.execute("CREATE TABLE IF NOT EXISTS users (username text, password text)") # 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 table cursor.execute("INSERT INTO users (username, password) VALUES (?, ?)", (username, password)) conn.commit() 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 table cursor.execute("SELECT * FROM users WHERE username=? AND password=?", (username, password)) if cursor.fetchone() is not None: 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.") # Finally, we'll close the connection to the database conn.close()