Back to Freecodecamp

Step 10

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

latest817 B
Original Source

--description--

The choice() function from the random module takes a sequence and returns a random item of the sequence.

Modify your print() call to use the choice() function and pass all_characters as the argument.

--hints--

You should modify your existing print() call to print random.choice(all_characters).

js
({ test: () => assert.match(code, /^print\s*\(\s*random\.choice\s*\(\s*all_characters\s*\)\s*\)/m) })

--seed--

--seed-contents--

py
import random
import string


# 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

print(all_characters)
--fcc-editable-region--
print(random.random())
--fcc-editable-region--