Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Stressful Subject by rossras
def is_stressful(subj):
"""
recoognise stressful subject
"""
if subj.isupper() or subj[-3:] == '!!!':
return True
clean_subj, last = [], ''
for ch in subj:
if ch != last and ch.isalpha():
clean_subj.append(ch.lower())
last = ch
clean_subj = ''.join(clean_subj)
for word in ('help', 'asap', 'urgent'):
if word in clean_subj:
return True
return False
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!')
Aug. 18, 2018