Password Strength

Lab Python Intermediate 20 points

Write strength(pw) returning strong if the password has at least 8 characters, an uppercase letter, a lowercase letter and a digit; medium if it meets 3 of the 4 rules; else weak.

Input

One password per line; the first line is the count n.

Output

One result per password.

Example

Input

3
Hello2026
hello2026
abc

Output

strong
medium
weak
Sample input available Sample output available
Editor
Python

Hints

any() is True if at least one item is true.

sum() of booleans counts the Trues.

Solution explanation

Collecting the rules in a list makes it easy to count how many passed.

Show solution
def strength(pw):
    rules = [
        len(pw) >= 8,
        any(c.isupper() for c in pw),
        any(c.islower() for c in pw),
        any(c.isdigit() for c in pw),
    ]
    passed = sum(rules)
    if passed == 4:
        return "strong"
    if passed == 3:
        return "medium"
    return "weak"


for _ in range(int(input())):
    print(strength(input()))
Output
Answer
HOME LEARN COMMUNITY DASHBOARD