title: How to read the value of a string stored in a text file, then convert to integer, and do math on value?
body: <p>I've been writing Python code for only about 4 weeks. I'm writing a little text based game to learn and test everything I know. I can easily make this work with a value entered into the console as an integer, but for whatever reason I can't get my code to work with reading this value from a text file.</p>
  
  <p>Earlier in the program, my code saves a value to a text file, just one value, then later it opens the same text file, over-writes the value with a new value based on a very simple calculation. That calculation is the first value, plus 5. I've spent a bunch of time reading on this site and going through my books and at this point I'm pretty sure I'm just missing something obvious.</p>
  
  <p>The first piece of code that creates the doc and sets the value:</p>
  
  <pre><code>def set_hp(self):
      f = open('player_hp.txt', 'w')
      self.hitpoints = str(int(self.hitpoints))
      f.write(self.hitpoints)
      f.close()
  </code></pre>
  
  <p>This is the trouble section...I have commented the line with the problem.</p>
  
  <pre><code>def camp_fire():
      print
      print "You stop to build a fire and rest..."
      print "Resting will restore your health."
      print "You gather wood from the ground around you. You spark\n\
  your flint against some tinder. A flame appears.\n\
  You sit, and close your eyes in weariness. A peaceful calm takes you\n\
  into sleep."
      f = open('player_hp.txt', 'r')
      orig_hp = f.readlines()
      orig_hp = str(orig_hp)
      f = open('player_hp.txt', 'w')
      new_value = orig_hp + 5    ##this is where my code breaks
      new_value = str(int(new_value))
      f.write(new_value)
      f.close()
      print "You have gained 5 hitpoints from resting. Your new HP are {}.".format(new_value)
  </code></pre>
  
  <p>This is the error I get:</p>
  
  <pre><code>  File "C:\Python27\Awaken03.py", line 300, in camp_fire
      new_value = orig_hp + 5
  TypeError: cannot concatenate 'str' and 'int' objects
  </code></pre>
  
  <p>I know you can't concatenate a string and an integer, but I keep trying different methods to convert the string to an integer to do the quick math, but I can't seem to get it right.</p>