我需要从我的标点符号中分离出我的单词-我正在考虑让函数查看每个单词并通过从 [-1] 开始,索引为 -1,然后拆分单词来确定其中是否有标点符号从标点符号,只要它碰到一个字母而不是标点符号......
sent=['I', 'went', 'to', 'the', 'best', 'movie!','Do','you', 'want', 'to', 'see', 'it', 'again!?!']
import string
def revF(List):
for word in List:
for ch in word[::-1]:
if ch is string.punctuation:
#go to next character and check if it's punctuation
newList= #then split the word between the last letter and first puctuation mark
return newList