title: Reading all numbers in file and calculate their total in python
body: <p>I am trying to count all numbers in given file. It works unless there is a word between a numbers.
  e.g: </p>
  
  <pre><code>1
  2
  car
  3
  4
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>def main():
  count=0
  with open("numbers.txt", "r") as f:
      try:
          line = f.readline()
          while line != '':
              print(line.strip())
              count += int(line)
              line = f.readline()
  
      except Exception as err:
          print(err)
  
      print(count)
  
  main()
  </code></pre>
  
  <p>I was thinking about continue, but it does only work with for or while. So is there any way?</p>