• + 1 comment
    from collections import Counter
    
    def validate(txt):
    
        #It must contain at least 2 uppercase English alphabet characters
        if sum([1 for x in txt if x.isupper()]) < 2:
            return False
    
        #It must contain at least 3 digits
        if sum([1 for x in txt if x.isdigit()]) < 3:
            return False
            
        #It should only contain alphanumeric characters 
        if not txt.isalnum():
            return False
    
        #No character should repeat.
        if (any(value != 1 for value in Counter(txt).values())):        
            return False
    
        #There must be exactly 10 characters in a valid UID.        
        if len(txt) != 10:
            return False
    
        
        return True
    
    n = int(input())
    for _ in range(n):
        txt = input().strip()
        print("Valid") if validate(txt) else  print("Invalid")