Learn Regular Expressions by Building a Password Generator - Step 71

I have passed a Generated password: string and new_password to my print() call.
But my code does not pass. I tried using the f-string. The code still does not pass. However I notice that in the console a password is generated each time I call the print() function. I have tried removing spaces, tried concatenating . The code still does not pass. Please help

Your code so far

import re
import secrets
import string

def generate_password(length=16, nums=1, special_chars=1, uppercase=1, lowercase=1):

    # 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
    return password

/* User Editable Region */

new_password = generate_password()
print('Generated password: ' + new_password)

/* User Editable Region */

Your browser information:

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

Challenge Information:

Learn Regular Expressions by Building a Password Generator - Step 71

Hello Zack,

Your string doesn’t need a space after :, also instead of +, can you think of a different character to seperate the 2 arguements?


Technically the output will be the same. The clue is here:

as the first argument,

So your print statement needs 2 arguments. Right now, you are concatenating 2 strings into 1 argument, but you need to pass 2 arguments to print()


Hi @HungryBee I can think of a comma to separate the two arguments. I will try that. The reason I put a space after the ‘:’ is because I notice in the console that without the space the string and the output of new_password are all close together. Okay let me try using the comma ‘,’

“Boom Shakalaka!” It passed. Thank you @HungryBee. Also I removed the space and it seems alright. Thanks


Yeah as pkdvalis said, it’s the difference btween conceatenating strings and making them in separate arguements. For some reason it wants the later here.