I have a list of strings s as follows:
s = ['Hello', 'world', '!', 'How', 'are', 'you', '?', 'Have', 'a', 'good', 'day', '.']
I want this list to be split into sublists. Whenever there's a ?!.\n a new sublist is formed as follows:
final = [['Hello', 'world', '!'],
['How', 'are', 'you', '?'],
['Have', 'a', 'good', 'day', '.']]
I tried this:
x = 0
for i in range(len(s)):
if s[i] in ('!','?','.','\n'):
final = s[x: x+i]
x = i+1
final stores my output. Not getting the way it should be. Any suggestions?