title: NameError: line is not defined
body: <p>Here is my short code:</p>
  
  <pre><code>import random
  lines = list()
  random.shuffle(line)
  for i, line in enumerate(open('Filename.txt')):
      if i &gt;= 21 and i &lt; 89:
         print (line, end='')
  </code></pre>
  
  <p>I am getting the error:</p>
  
  <pre><code>Traceback (most recent call last):
  File "/Users/macbookpro/Desktop/Dictionary2.py", line 3, in &lt;module&gt;
  random.shuffle(line)
  NameError: name 'line' is not defined
  </code></pre>
  
  <p>Now I understand the error, but I am having difficulty fixing it. When I comment out random.shuffle(line), my output prints successfully. But when I try to randomize it, random shuffle does not recognize 'line'. Why does print recognize 'line' but random.shuffle does not? How can I alter my code so that it does?</p>
  
  <p>[EDIT] When I adjust the code by changing 'line' to 'lines' I now get the following NameError:</p>
  
  <pre><code>  import random
    lines = list(lines)
    random.shuffle(lines)
    for i, line in enumerate(open('Filename.txt')):
        if i &gt;= 21 and i &lt; 89:
        print (line, end='')
  
  Traceback (most recent call last):
  File "/Users/macbookpro/Desktop/Dictionary2.py", line 2, in &lt;module&gt;
  lines = list(lines)
  NameError: name 'lines' is not defined
  </code></pre>
  
  <p>random.shuffle is still not reading what I put in there. What am I doing wrong?</p>