-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday_32.py
More file actions
38 lines (30 loc) · 1.31 KB
/
Copy pathday_32.py
File metadata and controls
38 lines (30 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Day 32: Password Validator
def password_validator():
while True:
password = input("Enter a password: ")
ch_upper = [caracter.isupper() for caracter in password]
ch_lower = [caracter.islower() for caracter in password]
numbers = [caracter.isdigit() for caracter in password]
if any(ch_upper) and any(ch_lower) and any(numbers) and len(password) > 7:
return password
elif not any(ch_upper):
print("Password must contain at least one capital letter")
elif not any(ch_lower):
print("Password must have at least one lowercase letter")
elif not any(numbers):
print("Password must have at least one number")
elif len(password) < 8:
print("Password must be at least eight characters")
print(password_validator())
print('-'*35)
# Extra Challenge: Valid Email
def email_validator(mail_lst):
valid_mail = []
for mail in mail_lst:
if '@' in mail and mail.count('@') == 1 and not mail.startswith('@') and mail.endswith('.com'):
valid_mail.append(mail)
else: continue
if valid_mail: return valid_mail
return "all emails are invalid"
emails = ['ben@mail.com', 'john@mail.cm', 'kenny@gmail.com', '@list.com']
print(email_validator(emails))