Lab 3 – Password Checker
Score: 0.1
Task: Write a program that compares a password and its confirmation. If they match, print "Password
accepted", otherwise print "Password
not accepted".
📌 Algorithm
- Read the password from the user.
- Read the confirmation from the user.
- Compare the two strings using
==. - If they match, print
"Password accepted". - Otherwise, print
"Password not accepted".
💻 Solution Code
password = input("Enter password: ")
confirm = input("Confirm password: ")
if password == confirm:
print("Password accepted")
else:
print("Password not accepted")
📤 Expected Output (examples)
Enter password: qwerty Confirm password: qwerty Password accepted
Enter password: qwerty Confirm password: Qwerty Password not accepted
📖 Step‑by‑Step Explanation
input()reads the password and confirmation as strings.- The
==operator compares the two strings exactly. - If they are equal, the
ifblock executes; otherwise, theelseblock executes. - Each block prints the corresponding message.
