Learn Regular Expressions by Building a Password Generator - Step 26

Tell us what’s happening:

i have add
constraints.append(('nums',' '))
but it show error

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

# User Editable Region

            password += secrets.choice(all_characters)
    constraints = []
    

# User Editable Region

    return password

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36

Challenge Information:

Learn Regular Expressions by Building a Password Generator - Step 26

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 (').

What is nums is that a string or a variable?

Can you please show the error it might show what’s wrong. Be sure to check the console for hints as well.

Welcome to the forum @nainishap263

Modify the constraints list assignment by adding a tuple to your list. Use nums as the first item and an empty string as the second item.

The instructions ask you to modify the constraints list, not append to it.

Also, look closely at the hint @pkdvalis gave regarding nums

Happy coding

thank you all of you and i got solution of it
– code removed–

2 Likes

Glad you got it! Please don’t post the solution to the forum though.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

solution code removed

Please do not post solution code.

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.