Given the following student data:
image
Write a Python code to print('Welcome student name') if both username and password entered by user match for that student. Note: Check first username and then password
Input Format
Username: 122
Password: Ghi122
Constraints
i) If entered username is not present in the list of usernames, then print Enter a valid username
ii) If entered password is not present in the list of passwords, then print Password Incorrect
iii) If both username and password belong to the same student, then print Welcome student_name
iv) If username and password do not belong to the same student, then print Username and password do not match
Output Format
Output: Welcome Ghi
for i in range(3):
username = input("Enter username: ")
password = input("Enter password: ")
if username == "122":
if password == "Ghi122":
print("Welcome " + username)
break
else:
print("\nPassword incorrect")
print("Try Again!\n")
else:
print("\nUsername incorrect")
print("Try Again!\n")
else:
print("No more attemps!")
Comments
Leave a comment