title: How to create a list or tuple of empty lists in Python?
body: <p>I need to incrementally fill a list or a tuple of lists. Something that looks like this:</p>
  
  <pre><code>result = []
  firstTime = True
  for i in range(x):
      for j in someListOfElements:
          if firstTime:
              result.append([f(j)])
          else:
              result[i].append(j)
  </code></pre>
  
  <p>In order to make it less verbose an more elegant, I thought I will preallocate a list of empty lists</p>
  
  <pre><code>result = createListOfEmptyLists(x)
  for i in range(x):
      for j in someListOfElements:
          result[i].append(j)
  </code></pre>
  
  <p>The preallocation part isn't obvious to me. When I do <code>result = [[]] * x</code>, I receive a list of <code>x</code> references to the same list, so that the output of the following</p>
  
  <pre><code>result[0].append(10)
  print result
  </code></pre>
  
  <p>is:</p>
  
  <pre><code>[[10], [10], [10], [10], [10], [10], [10], [10], [10], [10]]
  </code></pre>
  
  <p>I can use a loop (<code>result = [[] for i in range(x)]</code>), but I wonder whether a "loopless" solution exists.</p>
  
  <p>Is the only way to get what I'm looking for </p>