Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Stressful Subject by zinryu
def is_stressful(subj):
"""
recognize stressful subject
"""
ans = False
st = ['HELP','ASAP','URGENT']
subju = subj.upper()
ns = ''
for i in subju:
if ns == '' or (i.isalpha() and ns[-1] != i) or i == ' ':
ns += i
for j in st:
if ns.find(j) != -1:
ans = True
break
return (subj.isupper() or subj.endswith('!!!') or ans)
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("h!e!l!p") == True, "Second"
assert is_stressful("He loves peace") == False, "333"
assert is_stressful("We need you A.S.A.P.!!") == True, "333"
assert is_stressful("UUUURGGGEEEEENT here") == True, "333"
assert is_stressful("Headlamp, wastepaper bin and supermagnificently") == False, "333"
print('Done! Go Check it!')
March 27, 2020
Comments: