Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Stressful Subject by 9maksim
def is_stressful(subj):
from re import findall
red = ["help", "asap", "urgent"]
red_with_symbols = []
red_in_subj = []
for word in red:
word_with_symbols = ""
for letter in word:
word_with_symbols += letter + "+\W?"
red_with_symbols.append(word_with_symbols)
for word_with_symbols in red_with_symbols:
red_in_subj += findall(word_with_symbols, subj.lower())
return bool(red_in_subj) or subj[-3:] == "!!!" or subj.isupper()
if __name__ == '__main__':
#These "asserts" are only for self-checking and not necessarily for auto-testing
assert is_stressful("Hi") == False, "First"
assert is_stressful("I neeed HELP") == True, "Second"
assert is_stressful("A.S.A.P.") == True, "Second"
assert is_stressful("where are you?!!!!") == True, "Second"
print('Done! Go Check it!')
Dec. 1, 2019