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.
for _ in range(number):
UID = input()
UID_list = list(UID)
upper_count = 0
digit_count = 0
duplicate = False
lower_flag = False
UID_dic = dict.fromkeys(UID_list,0)
for i in UID_list:
if UID.isalnum() and len(UID) == 10 :
if i.isupper():
upper_count = upper_count+1
UID_dic[i] = UID_dic[i] +1
if i in ["0","1","2","3","4","5","6","7","8","9"]:
digit_count = digit_count+1
UID_dic[i] = UID_dic[i] +1
if i.islower():
lower_flag = True
UID_dic[i] = UID_dic[i] +1
for i in UID_list:
if UID_dic[i] > 1:
duplicate = True
break
if duplicate or upper_count < 2 or digit_count < 3 :
print("Invalid")
else:
print("Valid")
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 →
number = int(input())
for _ in range(number): UID = input() UID_list = list(UID)