title: Python codecademy digit_sum
body: <p>the task was discussed in 
  <a href="https://stackoverflow.com/questions/37948737/codecademy-practice-makes-perfect-digit-sum">codecademy Practice Makes Perfect digit_sum</a></p>
  
  <p>Where you need to sum the digits of a positive number.
  I use the string way to decide the task (not the floor dividing).</p>
  
  <p>My code is</p>
  
  <pre><code>def digit_sum (n):
      total = 0
      for digit in range(len(str(n))):
          total += int(n[digit])
      return total
  
  number = raw_input("Please print a long number: ")    
  print digit_sum(number)
  </code></pre>
  
  <p>It works all right with 1001 as well as with 434.</p>
  
  <p>However, the program says:
  Does your digit_sum function take exactly one argument (a positive integer)? Your code threw a "'int' object has no attribute '<strong>getitem</strong>'" error.</p>
  
  <p>What can be wrong when the code is working?</p>
  
  <p>Thanks!</p>