title: Correctly compute square root digital expansions
body: <p><a href="https://projecteuler.net/problem=80" rel="nofollow">Project Euler's problem number 80</a> reads:</p>
  
  <blockquote>
    <p>It is well known that if the square root of a natural number is not an
    integer, then it is irrational. The decimal expansion of such square
    roots is infinite without any repeating pattern at all.</p>
    
    <p>The square root of two is <code>1.41421356237309504880...</code>, and the digital
    sum of the first one hundred decimal digits is <code>475</code>.</p>
    
    <p>For the first one hundred natural numbers, find the total of the
    digital sums of the first one hundred decimal digits for all the
    irrational square roots.</p>
  </blockquote>
  
  <p>This is the code that I have produced for this question:</p>
  
  <pre><code>from decimal import *
  
  from math import sqrt
  
  getcontext().prec = 100
  
  
  def digitalsum(n):
      sum = 0
      for a in n:
          sum += int(a)
      return sum
  total = 0
  for a in range(1, 101):
      if not sqrt(a) % 1 == 0:
          ans = str(Decimal(a).sqrt())
          ans = ans[2::]
          print(a)
          print(digitalsum(ans))
          print("-------")
  
          total += digitalsum(ans)
  print(total)
  </code></pre>
  
  <p>It is showing up the wrong answer, and I presume I have missed something along the way. Any kind of help is appreciated.</p>