Learn Regular Expressions by Building a Password Generator - Step 26

Tell us what’s happening:

Hello! Someone can tell me what’s wrong with my code? Because the instruction is quite simple : You should add a tuple to the constraints list.

Your code so far

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)

# User Editable Region

        constraints = []
        constraints.append((nums, ''))
        

# User Editable Region

    return password

# new_password = generate_password(8)
# print(new_password)

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

Learn Regular Expressions by Building a Password Generator - Step 26

Oh! Thanks to me. I fix it by just replacing the empty list by [(nums, ‘’)]. I just literally add a tuple in my list.

Can you please provide the complete line of the solution? I am also getting the same.

He does explain it here. Don’t use a new line, just edit the original declaration to have a tuple in it instead of an empty list.

If you have further questions please open a new topic, thanks!