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.
Nice concise solution!
But, not an efficient one as you're looping through the string for every print.
s = input()
is_alpha = is_digit = is_lower = is_upper = False
for char in s:
if not is_alpha:
is_alpha = char.isalpha()
if char.isalpha():
if not is_lower:
is_lower = char.islower()
if not char.islower() and not is_upper:
is_upper = char.isupper()
else:
if not is_digit:
is_digit = char.isdigit()
print(is_alpha or is_digit)
print(is_alpha)
print(is_digit)
print(is_lower)
print(is_upper)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
String Validators
You are viewing a single comment's thread. Return to all comments →
Nice concise solution! But, not an efficient one as you're looping through the string for every print.