title: How to perform digitsum for a negative integer input until a single digit is obtained?
body: <p>My code:</p>
  
  <pre><code>def add_digits():
      num=int(input("Enter  "))
      return (num - 1) % 9 + 1 if num &gt; 0 else 0
  
  print(add_digits())
  </code></pre>
  
  <p>How to make this work for negative input? Please do help. Thanks in advance for your time and help.</p>