title: Print random line from txt file?
body: <p>I'm using random.randint to generate a random number, and then assigning that number to a variable. Then I want to print the line with the number I assigned to the variable, but I keep getting the error:</p>
  
  <blockquote>
    <p>list index out of range</p>
  </blockquote>
  
  <p>Here's what I tried:</p>
  
  <pre><code>f = open(filename. txt)
  lines = f.readlines() 
  
  rand_line = random. randint(1,10)
  print lines[rand_line]
  </code></pre>