Project: Username and Password Checker
Every signup form does two jobs: it turns a messy typed name into a tidy username, and it checks that a password is strong enough. You have all the string tools to build both.
What You'll Build
- Raw name' John Smith '
- Clean itstrip, lower, replace
- Usernamejohn_smith
Step 1: Make a Username
Start from a name a user might type, with stray spaces and mixed case. Chain string methods to standardize it: trim the ends, lowercase it, and swap spaces for underscores.
Loading Python Playground...
Step 2: Check the Password
A strong password here needs three things: at least 8 characters, at least one digit, and at least one uppercase letter. The any(...) helper returns True if any character passes the test:
Loading Python Playground...
Combine the three checks with and: the password is strong only if all three are True.
Build It Yourself
Produce the exact two lines below.
Loading Python Exercise...
Make It Your Own
Try a weak password and watch the result flip to False:
Loading Python Playground...
Challenge Ideas
- Print a specific reason when a password fails, like "needs a number"
- Also require a symbol such as
!or@ - Add a
@example.comemail built from the username
Key Takeaways
- Chain string methods to clean input in one readable line
any(test for c in text)checks whether any character passes- Combine boolean checks with
andfor an all-or-nothing rule - Real forms are just cleaning and checking, which you can now do

