Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
with groupby and any solution in Clear category for Stressful Subject by pavlik
def is_stressful(subj):
"""
recoognise stressful subject
"""
from itertools import groupby
s = ''.join(k for k, _ in groupby(subj.lower()) if k.isalpha())
return any(['help' in s,
'asap' in s,
'urgent' in s,
subj.endswith('!!!'),
subj.isupper()])
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert is_stressful("h!e!l!p") == True, 'bla'
assert is_stressful("Hi") == False, "First"
assert is_stressful("I neeed HELP") == True, "Second"
print('Done! Go Check it!')
Feb. 6, 2019
Comments: