Tell us what’s happening:
Now I am getting a little tired about this.
If it really wants me to call this anything special, this should be said in the assignment.
It asks me to add a fourth pattern to match any and combine the ones I have. Okey
I tied adding one, I removed the old ones and just had this one, but nothing is getting accepted.
Anyone have any clue? Is it the naming? Is it that I need them all + the new one or what? I feel the explanation in the assignment here could be so much better than what it is.
constraints = [
(non_alphanumeric, r'[^a-zA-Z0-9]'),
(special_chars, r''),
]
I have called it char, character, non_alphanumeric, pattern etc.
Also had this:
constraints = [
(nums, r'\d'),
(lowercase, r'[a-z]'),
(uppercase, r'[A-Z]'),
(special_chars, r'')
]
And then just added the new pattern to these so there is a 5th one inside the constraints etc. But I am not getting anywhere
Your code so far
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)
# User Editable Region
constraints = [
(non_alphanumeric, r'[^a-zA-Z0-9]'),
(special_chars, r''),
]
# User Editable Region
return password
# new_password = generate_password(8)
# print(new_password)
pattern = r'\.'
quote = 'Not all those who wander are lost.'
# print(re.findall(pattern, quote))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0
Challenge Information:
Learn Regular Expressions by Building a Password Generator - Step 47