Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Stressful Subject by Kurush
def is_stressful(subj):
letters = [char for char in subj if char.isalpha()]
filtered_letters = [letters[i] for i in range(len(letters)) if i == 0 or letters[i-1] != letters[i]]
filtered_string = "".join(filtered_letters)
return subj.isupper() or subj[-3:] == "!!!" or filtered_string.lower().find('help') != -1 or \
filtered_string.lower().find('asap') != -1 or filtered_string.lower().find('urgent') != -1
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert is_stressful("") == False, "Empty"
assert is_stressful("Hi") == False, "First"
assert is_stressful("I neeed HELP") == True, "Second"
assert is_stressful("I can do it!!!") == True, "Exclamations"
print('Done! Go Check it!')
Feb. 26, 2019
Comments: