title: How to read "n" lines at a time from stdin?
body: <p>Consider the stdin has the following entries:  </p>
  
  <pre><code>2  
  a     
  b     
  3
  d   
  e   
  f   
  </code></pre>
  
  <p>Now I would like to first read the number using <code>n= sys.stdin.readline()</code> 
  and then read the next <code>n</code> lines using a function <code>ReadNLines(n)</code> into a list.</p>
  
  <p>So the expected output is:</p>
  
  <pre><code>List1 = ['a','b']  
  List2 = ['d','e','f']
  </code></pre>
  
  <p>Here is what I have tried. And I am looking for better timing performance.</p>
  
  <pre><code>import sys
  def ReadNLines(n):
      List =[]
      for line in range(n):
          List.append(sys.stdin.readline())
      return List
  
  if __name__ == "__main__":
      n = sys.stdin.readline()
      List1 = ReadNLines(n)
      n = sys.stdin.readline()
      List2 = ReadNLines(n)
  </code></pre>