fork download
from itertools import accumulate, groupby
from operator import itemgetter

x = ['!test','hello','world','!echo','!embed','oh god']

cumsum = accumulate(map(lambda s: s.startswith('!'), x))
result = ['\n'.join(map(itemgetter(0), g)) for _, g in groupby(zip(x, cumsum), itemgetter(1))]

print(result)
Success #stdin #stdout 0.03s 9360KB
stdin
Standard input is empty
stdout
['!test\nhello\nworld', '!echo', '!embed\noh god']