程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python password

編輯:Python

Python password

Title Description

In the previous question , Pile The password set is ‘MAKIKAWAYI’ , Sensen thinks the password is too simple , So tell Pile, How to set a secure password . What kind of password is safe ? Generally speaking, a more secure password should meet at least the following two conditions :
(1). Password length is greater than or equal to 8 , And don't exceed 16.
(2). The characters in the password should come from “ Character category ” At least three of the four groups .

The four character categories are :
1. Capital :A,B,C…Z;
2. Lowercase letters :a,b,c…z;
3. Numbers :0,1,2…9;
4. Special symbols :~,!,@,#,$,%,^;

But there are too many rules , Sensen is also a little confused . So she gave you a password , She wants to ask you if the password is secure .

Input

The first line of input data contains a number M (M ≤ 50) , And then there's M That's ok , One password per line ( The maximum possible length is 50 ), The password only includes the above four types of characters .

Output

For each test case , Judge whether this password is a secure password , Yes, output YES , Otherwise output NO .

The sample input

3
a1b2c3d4
[email protected]
^~^@^@!%

Sample output

NO
YES
NO

Run code

num=int(input())
for i in range(0,num):
str=input()
if((len(str)<8)|(len(str)>16)):
print("NO")
continue
else:
kind=[0,0,0,0]
for c in range(0,len(str)):
if(str[c].isdigit()):
kind[0]=1
if(sum(kind)>=3):
print("YES")
break
elif(str[c].isupper()):
kind[1]=1
if (sum(kind) >= 3):
print("YES")
break
elif(str[c].islower()):
kind[2]=1
if (sum(kind) >= 3):
print("YES")
break
else:
kind[3]=1
if (sum(kind) >= 3):
print("YES")
break
if(c==(len(str)-1)):
print("NO")

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved