Learn Regular Expressions by Building a Password Generator - bug/error in code

I am on the last step of this and thought I would just test it with no lowercase and a length of 8.

Here is what happened:

As you can see, the second character of the password is a lower case a!

Is there a ‘bug/error’ in the code or have I done something wrong?

Here is my code (I have passed all the steps so far):

import re
import secrets
import string

def generate_password(length=16, nums=1, special_chars=1, uppercase=1, lowercase=1):

    # Define the possible characters for the password
    letters = string.ascii_letters
    digits = string.digits
    symbols = string.punctuation

    # Combine all characters
    all_characters = letters + digits + symbols

    while True:
        password = ''
        # Generate password
        for _ in range(length):
            password += secrets.choice(all_characters)
        constraints = [
            (nums, r'\d'),
            (special_chars, fr'[{symbols}]'),
            (uppercase, r'[A-Z]'),
            (lowercase, r'[a-z]')

        # Check constraints        
        if all(
            constraint <= len(re.findall(pattern, password))
            for constraint, pattern in constraints
    return password
new_password = generate_password()
print('Generated password:', new_password)

Here is the link to the course: