title: Python: Plug result of function back into itself until it reaches 1, or if it loops forever break and print(sad)
body: <p>I just started learning Python a few days ago, so forgive my crude work.</p>
  
  <pre><code>def sum_digits(n):
      s = 0
      while n:
          s += n % 10
          n //= 10
      return s
  
  def IsHappy(x):
      sum_digits(x**2)==1
      while True:
          print("happy number")
          break
      while False:
  </code></pre>
  
  <p>Basically, i want a function that tests if a number is a happy number
  <a href="https://en.wikipedia.org/wiki/Happy_number" rel="nofollow">https://en.wikipedia.org/wiki/Happy_number</a>
  I figured out how to make it say "happy number" if the value is 1 on the first try.
  However, if the value is not 1 on the first try, i want it to square the number, then sum the digits. I want it to repeat that until it gets 1. If it loops forever, i want it to print ("unhappy number").</p>
  
  <p>Thanks.</p>