We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
fromcollectionsimportCounterdefvalidate(txt):#It must contain at least 2 uppercase English alphabet charactersifsum([1forxintxtifx.isupper()])<2:returnFalse#It must contain at least 3 digitsifsum([1forxintxtifx.isdigit()])<3:returnFalse#It should only contain alphanumeric characters ifnottxt.isalnum():returnFalse#No character should repeat.if(any(value!=1forvalueinCounter(txt).values())):returnFalse#There must be exactly 10 characters in a valid UID. iflen(txt)!=10:returnFalsereturnTruen=int(input())for_inrange(n):txt=input().strip()print("Valid")ifvalidate(txt)elseprint("Invalid")
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Validating UID
You are viewing a single comment's thread. Return to all comments →