I am new to coding and python is my first programming language. I am studying with 'Automate the Boring Stuff', and right now I am in CH7- trying to figure out 'Strong Password Detection' project.
(https://automatetheboringstuff.com/2e/chapter7/)
Strong Password Detection
Write a function that uses regular expressions to make sure the password string it is passed is strong. A strong password is defined as one that is at least eight characters long, contains both uppercase and lowercase characters, and has at least one digit. You may need to test the string against multiple regex patterns to validate its strength.
I wrote a code like this below.
import re, pyperclip
password_regex = re.compile(r'^(?=.*[a-zA-Z0-9])(?=.*[!@#$%^&*-_]){8,}$')
text = pyperclip.paste()
matches = []
for groups in password_regex.findall(text):
matches.append(groups[0])
if len(matches)> 8:
pyperclip.copy('\n'.join(matches))
print('\n'.join(matches))
else:
print('Your password lenths doesn\'t meet the standard.')
It doesn't run anything after I saved it. Would you please help me and teach me what I did wrong? Thank you so much in advance.