Back to Freecodecamp

Step 15

curriculum/challenges/english/blocks/learn-regular-expressions-by-building-a-password-generator/65648e4c5b316c4ec5e4fddc.md

latest937 B
Original Source

--description--

At the bottom of your function, declare a password variable and assign an empty string to this variable.

--hints--

You should have a password variable inside your function with the value of an empty string. Pay attention to the indentation.

js
({ test: () =>
  {
    const transformedCode = code.replace(/\r/g, "");
    const generate_pw = __helpers.python.getDef("\n"+transformedCode, "generate_password");
    const {function_body} = generate_pw;     
    assert(function_body.match(/password\s*=\s*("|')\1/));
  }
})

--seed--

--seed-contents--

py
import secrets
import string


def generate_password(length):
    # 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--

--fcc-editable-region--