Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Stressful Subject by ad.thiers
import re
def is_stressful(subj):
"""
recognize stressful subject
"""
j = r'+\W?'
return (
subj.endswith('!!!') or
subj.isupper() or
bool(re.search(
j.join('help|') +
j.join('asap|') +
j.join('urgent'),
subj, flags=re.I)))
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("I uRgently need you") == True, "Second"
print('Done! Go Check it!')
Jan. 4, 2020
Comments: