title: What is the purpose of readline().strip()?
body: <h2><strong>What is the purpose of readline().strip() (especially in the below code)?</strong></h2>
  <p><strong>Context:</strong></p>
  <hr />
  <p>I was taking a look at the following code:</p>
  <pre><code>op = open('encyin.txt', 'r')
  n, q = op.readline().split()
  n = int(n)
  q = int(q)
  dic = {}
  
  for i in range(1, n + 1):
      dic[str(i)]=(op.readline().strip())
  </code></pre>
  <p>And trying to interpret it.</p>
  <hr />
  <p><strong>My Interpretation:</strong></p>
  <hr />
  <p>The start is simple enough - it opens a file <code>encyin.txt</code> in read mode. It takes input - <code>n</code> &amp; <code>p</code> - from the line, the <code>.split()</code> separating the two inputs. They are then classified as integers, and an empty list <code>dict</code> is created?</p>
  <p>From there, a <code>for</code> loop is utilised.</p>
  <p><strong>But what does the last line mean? I am not familiar with (a) <code>readline().strip()</code> and (b) how this affects list <code>dict</code> and the values of the input:</strong></p>
  <hr />
  <blockquote>
  <p><strong>For Example</strong></p>
  </blockquote>
  <p>If <code>ency.txt</code> was the following:</p>
  <pre><code>6 5
  1151
  723
  1321
  815
  780
  931
  </code></pre>
  <hr />
  <p>What happens to the other numbers from the 2nd line downwards? Does the <code>readline().split</code> assign them a line number? Does it add it to the list <code>dict</code>, a bit like <code>.append</code>?</p>
  <p><strong>What does the last line mean of the top code do? I am not familiar with (a) <code>readline().strip()</code> and (b) how this affects list <code>dict</code> and the values of the input:</strong></p>