In: Computer Science
Python
Implement a program that starts by asking the user to enter a login id (i.e., a string). The program then checks whether the id entered by the user is in the list ['joe', 'sue', 'hani', 'sophie'] of valid users. Depending on the outcome, an appropriate message should be printed. Regardless of the outcome, your function should print 'Done.' before terminating.
Here is an example of a successful login:
>>> Login: joe
You are in!
Done.
And here is one that is not:
>>> Login: john
User unknown.
Done.
SOURCE CODE:
LoginId=input("Enter LoginId of the user: ") #reading LoginId
from user
UsersList=['joe','sue','hani','sophie'] #List of userids
if LoginId in UsersList: #checking whether the LoginId is in
UsersList or not if yes,then
print("You are in!") #printing "You are in!" message to
console
print("Done.") #printing "Done." message to console
else: #if LoginId is not present in UsersList,then
print("User unknown.") #printing "User unknown" message to
console
print("Done.") #printing "Done." message to console
CODE SCREENSHOT:
OUTPUT: