result = []
for sub_l in words:
    result.append([])
temp = ''
for word in sub_l:
    if '!' in word:
        temp += ',' + word if temp else word
else:
    result[-1].append(word)
result[-1].append(temp)
Combine elements of lists if some condition