title: python read only integers from file
body: <p>I can't figure the way to read from this file, only the integers:</p>
  
  <pre><code>34
  -1
  2 48
    +0
  ++2
  +1
   2.4
  1000
  -0
  three
  -1  
  </code></pre>
  
  <p>The function should return:</p>
  
  <pre><code>[34, -1, 0, 1, -1]
  </code></pre>
  
  <p>If a number has <code>+</code> or <code>-</code> is valid. But if it has <code>++</code> or any letters is not.</p>
  
  <p>If it has a space (as for example <code>2 48</code> ) is not valid.</p>
  
  <p>If it is > 999 it is not valid.</p>
  
  <p>I am stuck only at here:</p>
  
  <pre><code>my_list = []
  with open('test.txt') as f:
      lines = f.readlines()
      for line in lines:
          my_list.append(line.strip())
  </code></pre>
  
  <p>I tried to make it a string and use punctuation using <code>translate</code> but I am not sure if it gets more complicated.</p>
  
  <p>Also, I am not sure about using regex. I tried a simple regex but I don't have experience using it.</p>