🐍 [Day 2] check_password()

April 21, 2026

Morning! πŸ˜ƒ β˜•οΈ

Yesterday you met the whole function.

Today, the first two lines are gone - the length check.

They're the easy ones. But now your brain has to reach for them instead of just reading them, and that little reach is exactly what turns "I've seen it" into "I know it."

Look at the blanks below and try to fill them in your head before you scroll.

In today's email...

THE FUNCTION 🐍

def check_password(password):
    ____________________
        ____________________
    has_number = False
    for char in password:
        if char.isdigit():
            has_number = True
    if has_number:
        return "Strong"
    return "Medium"

TODAY'S LINE πŸ’­

The two blanked lines are the length check:

    if len(password) < 8:
        return "Weak"

len(password) counts how many characters the password has. < 8 asks "is that fewer than eight?" If yes, the function returns "Weak" immediately.

Notice the second line is indented further than the first. In Python, indentation is how the language knows a line belongs inside the if - the return only runs when the condition is true.

And that return does something powerful: it ends the function on the spot. A too-short password never reaches the number check at all - there's no point, it's already weak. Catching the simplest failure first, then stopping, is a pattern you'll use in almost everything you write.

WITH ADA β˜•

Type the two missing lines back in, then head to Ada at py-and-jam.com.

Not sure why a line works the way it does? Ask Ada to explain it. Paste the function, point at the length check, and she'll walk you through what len() and < 8 are doing - in plain English, at your pace.

Quick test: run it on "short" and then on "muchlonger". Only the second clears the length gate.

ANSWER KEY βœ…

Today's blanked lines - the length check:

    if len(password) < 8:
        return "Weak"

The full function:

def check_password(password):
    if len(password) < 8:
        return "Weak"
    has_number = False
    for char in password:
        if char.isdigit():
            has_number = True
    if has_number:
        return "Strong"
    return "Medium"

See you tomorrow - the loop goes next. 🐍 The Py & Jam Team

There's a better way to learn.

Py & Jam delivers one memorable disappearing function to your inbox daily. It’s a simple, effective way to build fluency without the frustration.