Learn Regular Expressions by Building a Password Generator - Step 48

Tell us what’s happening:

I am not moving forward from step 48 and system is not accepting my solution

Your code so far

constraints = [
(nums, r’\D’),
(lowercase, r’[a-z]‘),
(uppercase, r’[A-Z]‘),
(special_chars, r’\W’)
]

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)

/* User Editable Region */

        constraints = [
            (nums, r'\D'),
            (lowercase, r'[a-z]'),
            (uppercase, r'[A-Z]'),
            (special_chars, r'[\W]')
        ]        

/* User Editable Region */

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

pattern = r'\.'
quote = 'Not all those who wander are lost.'
# print(re.findall(pattern, quote))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) 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 48

no need for [] brackets. just simply put \W inside '' quotes.

reset code and try again

constraints = [
            (nums, r'\D'),
            (lowercase, r'[a-z]'),
            (uppercase, r'[A-Z]'),
            (special_chars, r'\W')
        ]

This is the new code error still persisits

You capatalized the D in the first line next to nums. Can you change that and show us your code again but formatted.

You can use the </> button to format your code or write ``` before and after it.

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').