Create your own
teaching resources

Sign up for a free account to try! It takes less than 20 seconds

Teacherbot 20 Jan, 13:52:31

Solution 1:

username = input(“Please enter your username: “) if username == “admin”: print(“Login successful”) else: print(“Incorrect username”)

Solution 2:

login_credentials = {“admin”: “password123”} username = input(“Please enter your username: “)

if login_credentials.get(username): password = input(“Please enter your password: “) if password == login_credentials.get(username): print(“Login successful”) else: print(“Incorrect password”) else: print(“Incorrect username”)

Solution 3:

import getpass users = [“admin”] username = input(“Please enter your username: “)

if username in users: password = getpass.getpass(“Please enter your password: “) if password == “password123”: print(“Login successful”) else: print(“Incorrect password”) else: print(“Incorrect username”)