취미생활/CheckIO

[checkIO]Home 02. House Password

우주먼지의하루 2020. 2. 9. 13:35
728x90

Stephan and Sophia forget about security and use simple passwords for everything. Help Nikola develop a password security check module. The password will be considered strong enough if its length is greater than or equal to 10 symbols, it has at least one digit, as well as containing one uppercase letter and one lowercase letter in it. The password contains only ASCII latin letters or digits.

Input: A password as a string.

Output: Is the password safe or not as a boolean or any data type that can be converted and processed as a boolean. In the results you will see the converted results.

Example:

checkio('A1213pokl') == False

checkio('bAse730onE') == True

checkio('asasasasasasasaas') == False

checkio('QWERTYqwerty') == False

checkio('123456123456') == False

checkio('QwErTy911poqqqq') == True

* 10글자 이상으로 된 문자열이어야한다.

* 최소 하나의 숫자와 소문자, 대문자가 있어야한다.

* 문자열은 오직 대/소문자와 숫자로만 이루어져있다.

-풀이

 

def checkio(data: str) -> bool:
    
    #10글자 미만이면 False
    if len(data) < 10:
        return False
    
    data_digit = False
    data_lower = False
    data_upper = False
    
    for x in data:
        if x.isdigit():
            data_digit = True
        elif x.islower():
            data_lower = True
        elif x.isupper():
            data_upper = True

    # 전부 False면 True가 리턴
    if data_digit and data_upper and data_lower: 
        return True

 

반응형