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.
from collections import Counter
import re
n = int(input())
ls = []
for i in range(n):
a = input()
ls.append(a)
for i in ls:
c = Counter(i)
if len(i) <= 10:
if any(val > 1 for key , val in c.items()):
print('Invalid')
else:
upper = len(re.findall(r'[A-Z]',i))
digit = len(re.findall(r'[0-9]',i))
if upper >= 2 and digit >= 3:
print('Valid')
else:
print('Invalid')
else:
print('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 →
from collections import Counter import re n = int(input()) ls = [] for i in range(n): a = input() ls.append(a)
for i in ls: c = Counter(i) if len(i) <= 10: if any(val > 1 for key , val in c.items()): print('Invalid') else: upper = len(re.findall(r'[A-Z]',i)) digit = len(re.findall(r'[0-9]',i)) if upper >= 2 and digit >= 3: print('Valid') else: print('Invalid')