# Learn Regular Expression by Building a Password Generator step 67

**URL:** <https://forum.freecodecamp.org/t/learn-regular-expression-by-building-a-password-generator-step-67/743373>\
**Category:** Curriculum Help\
**Tags:** python\
**Created:** [April 14, 2025, 4:55am UTC](https://forum.freecodecamp.org/t/learn-regular-expression-by-building-a-password-generator-step-67/743373 "2025-04-14T04:55:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahmad12360](https://avatars.discourse-cdn.com/v4/letter/r/e0b2c6/32.png) [@rahmad12360](https://forum.freecodecamp.org/u/rahmad12360)\
**Post date:** [April 14, 2025, 4:55am UTC](https://forum.freecodecamp.org/t/learn-regular-expression-by-building-a-password-generator-step-67/743373/1 "2025-04-14T04:55:06Z")

</div>

```js
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'),
            (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
        ):
            break
    
    return password
    
new_password = generate_password(length=8, nums=1, special_chars=1, uppercase=1, lowercase=1)
print(new_password)

```

please help me !  
i dont know what is the change order for this course in step 67

---

<div class="post-metadata">

**Author:** ![rahmad12360](https://avatars.discourse-cdn.com/v4/letter/r/e0b2c6/32.png) [@rahmad12360](https://forum.freecodecamp.org/u/rahmad12360)\
**Post date:** [April 14, 2025, 5:00am UTC](https://forum.freecodecamp.org/t/learn-regular-expression-by-building-a-password-generator-step-67/743373/2 "2025-04-14T05:00:47Z")

</div>

im already change the length and nums, but still not pass

---

<div class="post-metadata">

**Author:** ![NateDhaliwal](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/natedhaliwal/32/328427_2.png) [@NateDhaliwal](https://forum.freecodecamp.org/u/NateDhaliwal)\
**Post date:** [April 14, 2025, 5:23am UTC](https://forum.freecodecamp.org/t/learn-regular-expression-by-building-a-password-generator-step-67/743373/3 "2025-04-14T05:23:57Z")

</div>

Please format your code in triple backticks, like so:

````auto
```py
Your code here...
```

````

Thanks.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [April 14, 2025, 8:20am UTC](https://forum.freecodecamp.org/t/learn-regular-expression-by-building-a-password-generator-step-67/743373/4 "2025-04-14T08:20:26Z")

</div>

can you give a link to the step?

* * *

I’ve edited your post to improve the readability of the code. 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.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (').

---

<div class="post-metadata">

**Author:** ![Teller](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/teller/32/412338_2.png) [@Teller](https://forum.freecodecamp.org/u/Teller)\
**Post date:** [April 14, 2025, 10:39pm UTC](https://forum.freecodecamp.org/t/learn-regular-expression-by-building-a-password-generator-step-67/743373/5 "2025-04-14T22:39:48Z")

</div>

Welcome to the forum @rahmad12360

> You should have the `(nums, '[0-9]')` tuple in your `constraints` list.

Also, remove the rest of the tuples. Then instructions did not ask you to add them in this step.

I changed the category to #Python to better reflect the nature of this post.

Happy coding

---

<div class="post-metadata">

**Author:** ![rahmad12360](https://avatars.discourse-cdn.com/v4/letter/r/e0b2c6/32.png) [@rahmad12360](https://forum.freecodecamp.org/u/rahmad12360)\
**Post date:** [April 16, 2025, 9:56pm UTC](https://forum.freecodecamp.org/t/learn-regular-expression-by-building-a-password-generator-step-67/743373/6 "2025-04-16T21:56:22Z")

</div>

thank you, you helped me a lot

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [October 16, 2025, 9:56am UTC](https://forum.freecodecamp.org/t/learn-regular-expression-by-building-a-password-generator-step-67/743373/7 "2025-10-16T09:56:32Z")

</div>

Closed on October 16, 2025, 9:56am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
