jmpark0118 / CODING_TEST_PRACTICE

0 stars 0 forks source link

Practice>Python>Regex and Parsing>Validating UID #101

Open jmpark0118 opened 3 years ago

jmpark0118 commented 3 years ago

image image

출처 : https://www.hackerrank.com/challenges/validating-uid/problem

jmpark0118 commented 3 years ago

import re

if __name__ == '__main__':
    for _ in range(int(input())):
        uid = input()
        if re.match(r'[a-zA-Z0-9]{10}', uid) is None:
            print("Invalid")
        elif len(list(uid)) != len(set(list(uid))):
            print("Invalid")
        else:
            step1 = len(re.findall(r'[A-Z]', uid))
            step2 = re.findall(r'[0-9]', uid)
            if step1 >= 2 and len(step2) >= 3:
                print("Valid")
            else:
                print("Invalid")