HackerRank Python - Validating UID




ABCXYZ company has up to 100 employees.
The company decides to create a unique identification number (UID) for each of its employees.
The company has assigned you the task of validating all the randomly generated UIDs.



  1. # Enter your code here. Read input from STDIN. Print output to STDOUT
  2. import re
  3. for _ in range(int(input())):
  4. u = ''.join(sorted(input()))
  5. try:
  6. assert re.search(r'[A-Z]{2}', u)
  7. assert re.search(r'\d\d\d', u)
  8. assert not re.search(r'[^a-zA-Z0-9]', u)
  9. assert not re.search(r'(.)\1', u)
  10. assert len(u) == 10
  11. except:
  12. print('Invalid')
  13. else:
  14. print('Valid')




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube