title: I can not seem to figure out why I can't convert to an int
body: <p>I am trying to convert an string into an int but for some reason it does seem to want to work. I am very interested in learning where there is a disconnect in my understanding of the code written. Thank you!</p>
  
  <pre><code>def fourdigitnum(num):
      string = str(num)
      while (len(string) &lt; 4):
          string = "0" + string
      return string
  def ascend_desend(string,order):
      if(order == "ascend"):
          string = sorted(string,reverse = True)
      elif(order == "descend"):
          string = sorted(string,reverse = False)
      return string
  def list_to_num(lst):
      string = ""
      for ele  in lst:
          string = string + ele
      return int(string)
  
  def KaprekarsConstant(num): 
      num = int(num)
      count = 0
      while num != 6174:
          num = fourdigitnum(num)
          #ascend and descend are lists
          ascend = ascend_desend(num,"ascend")
          descend = ascend_desend(num,"descend")
          #they must be turned into nums
          ascend = list_to_num(ascend)
          descend = list_to_num(descend)
          num = descend - ascend
          count += 1
  
      return count
  
  print KaprekarsConstant(raw_input())  
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/tmp/576159006/main.py", line 41, in &lt;module&gt;
      print KaprekarsConstant(2111)
    File "/tmp/576159006/main.py", line 33, in KaprekarsConstant
      ascend = list_to_num(ascend)
    File "/tmp/576159006/main.py", line 16, in list_to_num
      return int(string)
  ValueError: invalid literal for int() with base 10: '999-'
  </code></pre>