Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Stressful Subject by lukasz.bogaczynski
import re
is_message_stressfull_regex = re.compile(r"((.*h+\W*e+\W*l+\W*p+\W*)+)|((.*u+\W*r+\W*g+\W*e+\W*n+.*t+\W*)+)|((.*a+\W*s+\W*a+\W*p+\W*)+)|(.*!{3,}$)", re.IGNORECASE)
def is_stressful(email):
return is_all_upper_case(email) or is_message_stressfull_regex.match(email) != None
def is_all_upper_case(email):
for character in email:
if character.islower():
return False
return True
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!')
Nov. 16, 2017
Comments: