nlp100.github.io
import re
s = 'Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.'
s_sub = re.sub('[,.]', '', s)
print(s_sub)
s_split = s_sub.split()
print(s_split)
len_list = list(map(len, s_split))
print(len_list)
$ python3 03.py
Now I need a drink alcoholic of course after the heavy lectures involving quantum mechanics
['Now', 'I', 'need', 'a', 'drink', 'alcoholic', 'of', 'course', 'after', 'the', 'heavy', 'lectures', 'involving', 'quantum', 'mechanics']
[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9]