Aprende Expresiones Regulares para Construir un Generador de Contraseñas - Paso 66

Cuéntanos qué está pasando:

Can someone tell me where the error is, because I’m not understanding what the logic is if length doesn’t take it.

Tu código hasta el momento

import re
import secrets
import string


def generate_password(length, nums, special_chars, uppercase, lowercase):

    # 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
        ):
            break

    return password


# User Editable Region

new_password = generate_password(length, nums, special_chars, uppercase, lowercase)
print(new_password)
new_password(length=8, nums=1,special_chars=1, uppercase=1, lowercase=1)

# User Editable Region

Información de tu navegador:

El agente de usuario es: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36

Información del Desafío:

Aprende Expresiones Regulares para Construir un Generador de Contraseñas - Paso 66

Modify your function call to use keyword arguments.

That means you should not have a new function call but change the one that was already there

What happens is that it does not recognize length in the first argument of generate_password

have you tried changing this call?

also, new_password is not a function, the function is generate_password, whatever you do this is making everything error our