---
id: 656ef783bba6976de014eaa8
title: Step 24
challengeType: 20
dashedName: step-24
---

# --description--

Put your `password` variable declaration and the following `for` loop inside a `while` loop. Use `True` as the condition for your new loop.

# --hints--

You should create a `while True` loop enclosing your existing `password` declaration and `for` loop.

```js
({ test: () => {
    
    const commentless_code = __helpers.python.removeComments(code);
    const {block_body} = __helpers.python.getBlock(commentless_code, /while\s+True\s*/);
    assert(block_body.match(/^\s+password\s*=\s*("|')\1\s*^\s+for\s+_\s+in\s+range\s*\(\s*length\s*\s*\)\s*:\s*^\s+password\s*\+=\s*secrets\.choice\s*\(\s*all_characters\s*\)\s*$/m));    
    const {block_body: for_body} = __helpers.python.getBlock(commentless_code, /for\s+_\s+in\s+range\s*\(\s*length\s*\s*\)\s*/);
    assert(for_body.match(/^\s+password\s*\+=\s*secrets\.choice\s*\(\s*all_characters\s*\)\s*$/m));  
  }
})
```

# --seed--

## --seed-contents--

```py
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
--fcc-editable-region--
    password = ''
    # Generate password
    for _ in range(length):
        password += secrets.choice(all_characters)
--fcc-editable-region--        
    return password

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