I made a password strength checker Code:
import re
upper = re.compile(r'[A-Z]')
lower = re.compile(r'[a-z]')
digit = re.compile(r'[0-9]')
special_char = re.compile(r'[~!@#$%^&*()]')
# text = 'd3F#$%^&232sdsGDFD'
text = input("Enter a password to check it's strength\n")
digit_check = digit.search(text)
upper_check = upper.search(text)
lower_check = lower.search(text)
special_char_chk = special_char.search(text)
if digit_check and upper_check and lower_check and special_char_chk and len(text)>=8:
print("Valid password\nPassword is:" + text)
else:
print("Innvalid")
I tried to make it as short at my level. How far can I reduce the number of code lines?