Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Stressful Subject by Sarina
import re
def is_stressful(subj):
"""
recoognise stressful subject
"""
clean = re.sub("[-!\.]","", subj)
# all letters are in uppercase
c1 = subj.isupper()
# ends by at least 3 exclamation marks
c2 = bool(re.match(".*!{3,}$", subj))
# contains at least one of the following “red” words: "help", "asap", "urgent"
c3 = bool(re.match("(.* )?(h+e+l+p+|u+r+g+e+n+t+|a+s+a+p+)( .*)?", clean, re.I))
return any([c1,c2,c3])
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert is_stressful("Hi") == False, "First"
assert is_stressful("I neeed HELP") == True, "Second"
print('Done! Go Check it!')
May 19, 2019