Learn Regular Expressions by Building a Password Generator - Step 61

Tell us what’s happening:

i have a problem with passing step 61. i have put the code already as is and the break after it, and it kept instructing me to put a break inside the new if statement that I did. please help

Your code so far

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'),
            (lowercase, r'[a-z]'),
            (uppercase, r'[A-Z]'),            
            (special_chars, fr'[{symbols}]')            
        ]

        # Check constraints
        count = 0

# User Editable Region

        if all(constraint <= len(re.findall(pattern, password))for constraint, pattern in constraints):
            break

# User Editable Region

            break

    return password

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36

Challenge Information:

Learn Regular Expressions by Building a Password Generator - Step 61

Replace your existing for loop and two if statements with a single if statement. For the if condition, use a call to the all() function and pass an empty list as the argument to the function call.

I don’t understand where did this come from:

You should pass an empty list to all(). Also, you have two consecutive breaks.

how do i pass and empty all() to this? also, that was typo with the second break, I did emit the other ‘break’ and it is still saying to put a break in the if body

if all(constraint <= len(re.findall(pattern, password)) for constraint, pattern in constraints):
break
this is my updated

You see that message because of the way the test is built.
Do you know how to create an empty list?

I assumed it’s with brackets. do I put these brackets around? I have just started doing this a couple weeks ago and learning as I go, but today seemed like a big hit of ‘huh?’ to me.

I. Got. It. -__- too close to my face. Thank you!

how did you get it? please help lol

Please open a new topic and share your 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 Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for 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.

So hard to understand the lesson topic.
please, try it.
– removed

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

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.