curriculum/challenges/english/blocks/learn-regular-expressions-by-building-a-password-generator/6564b8c9349bd76dc037967b.md
The search() function from the re module analyzes the string passed as the argument looking for the first place where the regex pattern matches the string.
Declare a variable called quote and assign the string 'Not all those who wander are lost.' to this variable. Then, print the result of pattern.search(quote).
You should have a quote variable.
({ test: () => assert(__userGlobals.has("quote")) })
You should assign the provided string to your new quote variable.
({ test: () => assert.equal(__userGlobals.get("quote"), "Not all those who wander are lost.") })
You should print pattern.search(quote).
({ test: () => assert.match(code, /^print\s*\(\s*pattern\.search\s*\(\s*quote\s*\)\s*\)/m) })
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, '')
]
return password
# new_password = generate_password(8)
# print(new_password)
--fcc-editable-region--
pattern = re.compile('i')
--fcc-editable-region--