Hi guys, if I would to put ' symbol in the symbols, it is obvious that I won't be getting the desire outcome.
I would like to preserve the ' symbol on don't isn't and wouldn't. I've tried with endswith method but still got it wrong. Hope you could help on this.
Current outcome
["Examples", "of", "contractions", "include", "dont", "isnt", "and", "wouldnt"]
Desire outcome
["Examples", "of", "contractions", "include", "don’t", "isn’t", "and", "wouldn’t"]
I would like to preserve the ' symbol on don't isn't and wouldn't. I've tried with endswith method but still got it wrong. Hope you could help on this.
Current outcome
["Examples", "of", "contractions", "include", "dont", "isnt", "and", "wouldnt"]
Desire outcome
["Examples", "of", "contractions", "include", "don’t", "isn’t", "and", "wouldn’t"]
sentence = "Examples of contractions include: don't, isn't, and wouldn't" list_sentence = sentence.split() print(list_sentence) symbols = "{}()[].,:;-*/&|<>=~$123456789?" results = [] for element in list_sentence: temp = "" for ch in element: if ch not in symbols: temp += ch results.append(temp) print(results)