In this exercise you will create a program that identifies all of the words in a string entered by the user. Begin by writing a function that takes a string of text as its only parameter.Your function should return a list of the words in the string with the punctuation marks at the edges of the words removed. The punctuation marks that you must remove include commas, periods, question marks, hyphens, apostrophes, exclamation points, colons, and semicolons. Do not remove punctuation marks that appear in the middle of a words, such as the apostrophes used to form a contraction. For example, if your function is provided with the string "Examples of contractions include: don’t, isn’t, and wouldn’t." then your function should return the list["Examples", "of", "contractions", "include", "don’t", "isn’t", "and", "wouldn’t"].
Hint:
As this exercise uses functions you should be familiar with them before you try to solve this one.
def remove_punctation(inStr): list_of_words = inStr.split() list_of_words =[el.lower().rstrip('\'\"-,.:;!?') for el in list_of_words] return list_of_words def main(): print(remove_punctation("Examples of contractions include: don't, isn't, and wouldn't.")) if __name__ == '__main__': main()