Practice

Password Length Validation

2025/May/Jun·Variant 3
EASYLoops

A password must contain at least 12 characters. Write an algorithm that prompts a user to enter a password. If it is less than 12 characters, output "Password too short, please try again" and ask again. Repeat until valid, then output "Password accepted".

Input: One or more strings representing password attempts. Output: Error messages for each invalid attempt, then the success message.

Example:

Input:  short
        thisislongenough
Output: Password too short, please try again
        Password accepted
Premium is coming soon. All grading features are currently unlocked.

Sample Test Cases

Test 1: One invalid then valid
Inputs: tooshort, validpassword123
Expected: Password too short, please try again Password accepted
Test 2: Exactly 12 characters
Inputs: exactlytwelv
Expected: Password accepted
Test 3: Two invalid then valid
Inputs: 123, 456, superlongpassword
Expected: Password too short, please try again Password too short, please try again Password accepted
Press Ctrl+Enter to run your code
or Ctrl+Shift+Enter to grade