title: How to create a 2d nested list from a text file using python?
body: <p>I'm a beginner programmer, and I'm trying to figure out how to create a 2d nested list (grid) from a particular text file. For example, the text file would look like this:</p>
  <pre class="lang-none prettyprint-override"><code>3
  3
  150
  109
  80
  892
  123
  982
  0
  98
  23
  </code></pre>
  <p>The first two lines in the text file would be used to create the grid, meaning that it is 3x3. The next 9 lines would be used to populate the grid, with the first 3 making up the first row, the next 3 making up the middle row, and the final 3 making up the last row. So the nested list would look like this:</p>
  <pre><code>[[150, 109, 80] [892, 123, 982] [0, 98, 23]]
  </code></pre>
  <p>How do I go about doing this? I was able to make a list of all of the contents, but I can't figure out how to use the first 2 lines to define the size of the inner lists within the outer list:</p>
  <pre><code>lineContent = []
  innerList = ?
       for lines in open('document.txt','r'):
       value = int(lines)
       lineContent.append(value)
  </code></pre>
  <p>From here, where do I go to turn it into a nested list using the given values on the first 2 lines?</p>
  <p>Thanks in advance.</p>