2013-09-26 3 views
-1

사용자는 암호를 입력해야하지만 암호에는 대문자, 소문자 및 숫자가 하나 이상 있어야합니다.입력이 요구 사항을 충족하는지 확인하는 방법

password = input("Please enter a password: ") 
또한 이러한 조건까지 멈추지 않을 것 while 루프에 넣을 수
+3

시도는 그것의 한 부분을 해결하기 위해. 나머지는 쉬울 것입니다. 붙어 있다면 당신이 시도한 것을 보여주십시오. –

답변

4
if any(x.isupper() for x in password) and \ 
    any(x.islower() for x in password) and \ 
    any(x.isdigit() for x in password): 
    print ("Congratulations, you have a secure password.") 
1

이 일치 :

while True: 
    password = input("Please enter a password: ") 
    if any(x.isupper() for x in password) and \ 
     any(x.islower() for x in password) and \ 
     any(x.isdigit() for x in password): #copy from Rob's awnser 
      break 

    else: print('Invalid!') 
관련 문제