This is a Python function checkUserInput
that takes username
and password
as parameters and checks if they match the predefined values of name
and pw
.
The code then takes input from the user for username
and password
and calls the checkUserInput
function with the input values. If the function returns True
, it prints “Successfully logged in”. If the function returns False
, it prints “Wrong username or password”.
def checkUserInput(username, password):
name, pw = "user", "123456"
if name == username and pw == password:
return True
else:
return False
username = input("Enter username: ")
password = input("Enter password: ")
if checkUserInput(username, password):
print("Successfully logged in")
else:
print("Wrong username or password")
Enter username: user
Enter password: 123456
Successfully logged in
Enter username: adsf
Enter password: 123456
Wrong username or password