Last active
March 5, 2019 06:33
-
-
Save MikeLing/5c4dc1a0a5b609d2950fe6bc8f8a5ff2 to your computer and use it in GitHub Desktop.
Revisions
-
MikeLing revised this gist
Mar 5, 2019 . 1 changed file with 10 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,8 +22,15 @@ def is_stressful(subj): return True # check if it end up with exclamation marks. reversed_words = subj[::-1] counter = 0 for i in reversed_words: if i == '!': counter = counter + 1 else: break if counter >= 3: return True # check if it has red words. @@ -36,4 +43,5 @@ def is_stressful(subj): if __name__ == "__main__": print (is_stressful("We need you A.S.A.P.!!")) print (is_stressful("Where are you?!!!")) print (is_stressful("Heeeeeeey !!!!! I'm having so much fun!")) -
MikeLing revised this gist
Mar 5, 2019 . 1 changed file with 4 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,8 @@ def is_stressful(subj): return True # check if it end up with exclamation marks. trace_back = subj.split('!')[-1] if trace_back.count('!') >= 2: return True # check if it has red words. @@ -34,11 +35,5 @@ def is_stressful(subj): return False if __name__ == "__main__": print (is_stressful("We need you A.S.A.P.!!")) print (is_stressful("Heeeeeeey !!!!! I'm having so much fun!")) -
MikeLing revised this gist
Mar 5, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ from collections import OrderedDict RED_WORDS = ['help', 'asp', 'urgent'] def check_red_words(word): # deal with the word -
MikeLing revised this gist
Mar 5, 2019 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ def check_red_words(word): return True if lower_word in RED_WORDS else False def is_stressful(subj): # check if all the letters are uppercase. if subj.isupper(): return True @@ -34,11 +34,11 @@ def if_stressful(subj): return False if __name__ == "__main__": print (is_stressful("It's stressful !!!")) print (is_stressful("STRESSFUL TITLE")) print (is_stressful("STRESSFUL TITLE !!!!!")) print (is_stressful("STRESSFUL TITLE !!")) print (is_stressful("HELLLLLLLLLLP")) print (is_stressful("HEEELLLLLL-LL-L-LP")) print (is_stressful("help")) print (is_stressful("It's not ")) -
MikeLing created this gist
Mar 5, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ from collections import OrderedDict RED_WORDS = ['help', 'asap', 'urgent'] def check_red_words(word): # deal with the word # remove_duplicate = "".join(OrderedDict.fromkeys(word)) temp = [] for i in word: if i not in temp and i.isalpha(): temp.append(i) remove_duplicate = ('').join(temp) lower_word = remove_duplicate.lower() return True if lower_word in RED_WORDS else False def if_stressful(subj): # check if all the letters are uppercase. if subj.isupper(): return True # check if it end up with exclamation marks. if subj.count('!') >= 3: return True # check if it has red words. split_string = subj.split() for w in split_string: if check_red_words(w): return True return False if __name__ == "__main__": print (if_stressful("It's stressful !!!")) print (if_stressful("STRESSFUL TITLE")) print (if_stressful("STRESSFUL TITLE !!!!!")) print (if_stressful("STRESSFUL TITLE !!")) print (if_stressful("HELLLLLLLLLLP")) print (if_stressful("HEEELLLLLL-LL-L-LP")) print (if_stressful("help")) print (if_stressful("It's not "))