Step 24 - Learn regular expressions by building a password generator

Hi there guys, I’m really struggling with this step. I feel like I’ve done everything 100% right but I must be slipping up somewhere as it wont accept this answer.

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

My code:

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

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

The snippet I’m meant to edit:

while True:
    password = ''
    # Generate password
    for _ in range(length):
        password += secrets.choice(all_characters)

Thanks for any help!

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

while True needs to be indented 4 spaces to be inside the function, and the things that need to be inside the while loop also need to be indented appropriately