Validating UID in Python HackerRank Solution

Hello Programmers, In this post, you will know how to solve the Validating UID in Python HackerRank Solution. This problem is a part of the HackerRank Python Programming Series.

Validating UID in Python HackerRank Solution
Validating UID in Python HackerRank Solutions

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Hackerrank by yourself. If you find any difficulty after trying several times, then you can look for solutions.

Validating UID in Python HackerRank Solution


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.A valid UID must follow the rules below:

  • It must contain at least 2 uppercase English alphabet characters.
  • It must contain at least 3 digits ( 0 – 9).
  • 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.

Input Format :

The first line contains an integer T, the number of test cases.
The next T lines contains an employee’s UID.

Output Format :

For each test case, print ‘Valid’ if the UID is valid. Otherwise, print ‘Invalid’, on separate lines. Do not print the quotation marks.

Sample Input :


Sample Output :


Explanation :

B1CD102354: 1 is repeating → Invalid
B1CDEF2354: Valid 

Validating UID in Python HackerRank Solutions

import re
for i in range(int(input())):
    N = input().strip()
    if N.isalnum() and len(N) == 10:
        if bool('(.*[A-Z]){2,}',N)) and bool('(.*[0-9]){3,}',N)):

Disclaimer: The above Problem (Validating UID in Python) is generated by Hackerrank but the Solution is Provided by BrokenProgrammers. This tutorial is only for Educational and Learning purposes.

Next: Validating Credit Card Numbers in Python HackerRank Solution

Leave a Reply

Your email address will not be published. Required fields are marked *