title: How to split a list-of-strings into sublists-of-strings by a specific string element
body: <p>I have a word list like below. I want to split the list by <code>.</code>. Is there any better or useful code in Python 3?</p>
  
  <pre><code>a = ['this', 'is', 'a', 'cat', '.', 'hello', '.', 'she', 'is', 'nice', '.']
  result = []
  tmp = []
  for elm in a:
      if elm is not '.':
          tmp.append(elm)
      else:
          result.append(tmp)
          tmp = []
  print(result)
  # result: [['this', 'is', 'a', 'cat'], ['hello'], ['she', 'is', 'nice']]
  </code></pre>
  
  <h2>Update</h2>
  
  <p>Add test cases to handle it correctly.</p>
  
  <pre><code>a = ['this', 'is', 'a', 'cat', '.', 'hello', '.', 'she', 'is', 'nice', '.']
  b = ['this', 'is', 'a', 'cat', '.', 'hello', '.', 'she', 'is', 'nice', '.', 'yes']
  c = ['.', 'this', 'is', 'a', 'cat', '.', 'hello', '.', 'she', 'is', 'nice', '.', 'yes']
  def split_list(list_data, split_word='.'):
      result = []
      sub_data = []
      for elm in list_data:
          if elm is not split_word:
              sub_data.append(elm)
          else:
              if len(sub_data) != 0:
                  result.append(sub_data)
              sub_data = []
      if len(sub_data) != 0:
          result.append(sub_data)
      return result
  
  print(split_list(a)) # [['this', 'is', 'a', 'cat'], ['hello'], ['she', 'is', 'nice']]
  print(split_list(b)) # [['this', 'is', 'a', 'cat'], ['hello'], ['she', 'is', 'nice'], ['yes']]
  print(split_list(c)) # [['this', 'is', 'a', 'cat'], ['hello'], ['she', 'is', 'nice'], ['yes']]
  </code></pre>