02_python闯关练习_01Password

 判断密码是否:

  1. 长度大于10;

  2. 包含数字;

  3. 包含大写字母;

  4. 包含小写字母。

 1 # Author:Zhang Yide
 2 # coding:utf-8
 3 
 4 def password(data):
 5     '''Check if password inputed is strong enough
 6 
 7     Its length is greater than or equal to 10 symbols;
 8     It has at least one digit;
 9     It has at least one uppercase letter and lowercase letter'''
10 
11     data = str(data)
12     HasDigit = any(i.isdigit() for i in data)
13     HasUpper = any(i.isupper() for i in data)
14     HasLower = any(i.islower() for i in data)
15     if HasDigit and HasUpper and HasLower and len(data) >= 10:
16         return True
17     else:
18         return False
19 
20 while True:
21     data = input("please input password:
")
22     print(password(data))
原文地址:https://www.cnblogs.com/zhangyide/p/8214635.html