-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAcceptable_Password.py
32 lines (25 loc) · 1.33 KB
/
Acceptable_Password.py
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
# The length should be bigger than 6;
# Should contain at least one digit.
def is_acceptable_password_2(password: str) -> bool:
# your code here
return True if len(password)>6 and any([x.isdigit() for x in password]) else False
if __name__ == '__main__':
print("Example 1:")
print(is_acceptable_password_2('short')) #== False
print(is_acceptable_password_2('muchlonger')) #== False
print(is_acceptable_password_2('ashort')) #== False
print(is_acceptable_password_2('muchlonger5')) # == True
print(is_acceptable_password_2('sh5')) #== False
# The length should be bigger than 6;
# Should contain at least one digit, but cannot consist of just digits.
def is_acceptable_password_3(password: str) -> bool:
# your code here
return True if len(password)>6 and not(password.isnumeric()) and any([x.isdigit() for x in password]) else False
if __name__ == '__main__':
print("\nExample 2:")
print(is_acceptable_password_3('short')) # == False
print(is_acceptable_password_3('muchlonger')) # == False
print(is_acceptable_password_3('ashort')) # == False
print(is_acceptable_password_3('muchlonger5')) # == True
print(is_acceptable_password_3('sh5')) # == False
print(is_acceptable_password_3('1234567')) # == False