attempts = 0
while attempts < 3:
password = input("Enter password: ")
if password == "admin123":
print("Access granted")
break
else:
attempts += 1
print("Incorrect password")
if attempts == 3:
print("Account locked")
Demonstrates brute-force protection logic.
Next Lesson →