title: Python - ValueError: invalid literal for int() with base 10: 'hello'
body: <p>I get the following error on python 2.7 . 'Hello' is last word in a line from the text file.The following solutions did not work for me <a href="https://stackoverflow.com/questions/38319409/valueerror-invalid-literal-for-int-with-base-10-height-mm">ValueError: invalid literal for int() with base 10: &#39;Height (mm)&#39;</a></p>
  
  <pre><code>ValueError: invalid literal for int() with base 10: 'hello.'
  </code></pre>
  
  <p>when executing the following code</p>
  
  <pre><code>import io
  
  with io.open(r'C:\Python\Data\somefile.txt','r+') as f:
      bytecolumn = (line.rsplit(None,1)[1] for line in f)
      bytes = (int(x) for x in bytecolumn if x != '-')
      print('Total', sum(bytes))
  </code></pre>
  
  <p>I also tried using </p>
  
  <pre><code>int(float(x))
  </code></pre>
  
  <p>but it throws the error</p>
  
  <pre><code>ValueError: could not convert string to float: hello.
  </code></pre>
  
  <p>P.S - I have looked at all similar questions here in stack overflow , none of the solutions worked. That is the reason to post. Please don't mark duplicate</p>
  
  <p><strong>Edit</strong> : I am trying to find the size of the word . that is the reason I am doing a sum and calling generators</p>