import re
u,d,c=0,0,0
n=int(input())
for i in range(0,n):
uid=str(input())
uid = "".join(sorted(uid))
if (len(uid)<=10):
for i in uid:
if(re.search("[a-z]", uid)):
flag=-1
if(re.search("[0-9]", uid)):
flag=-1
if(re.search("[A-Z]", uid)):
flag=-1
if(uid.count(i)>1):
c+=1
if(i.isupper()): #uppercase
u+=1
if(i.isdigit()):
d+=1
if(u>=2 and d>=3 and flag==-1 and c==0):
print("Valid")
else:
print("Invalid")
The above code is for validating uid(string).
When I pass 2 values and when the 1st value is invalid then it is correctly validated and prints "invalid" then for next value even if it is valid, it still prints "invalid". Whereas, if 1st value is valid it prints "valid" and if the next value is invalid it prints "invalid".
Added image for reference(in image 1st value is invalid because of repeated characters but 2nd value is valid, still showing invalid)

Rules for Validating uid:
It must contain at least 3 digits (0-9).
It must contain at least 2 uppercase English alphabet characters.
It should only contain alphanumeric characters (a-z, A-Z & 0-9 ).
No character should repeat.
There must be exactly 10 characters in a valid UID.