title: How do I find the difference between two values without knowing which is larger?
body: <p>I was wondering if there was a function built into Python that can determine the distance between two rational numbers but without me telling it which number is larger.
  e.g.</p>
  
  <pre><code>&gt;&gt;&gt;distance(6,3)
  3
  &gt;&gt;&gt;distance(3,6)
  3
  </code></pre>
  
  <p>Obviously I could write a simple definition to calculate which is larger and then just do a simple subtraction:</p>
  
  <pre><code>def distance(x, y):
      if x &gt;= y:
          result = x - y
      else:
          result = y - x
      return result
  </code></pre>
  
  <p>but I'd rather not have to call a custom function like this.
  From my limited experience I've often found Python has a built in function or a module that does exactly what you want and quicker than your code does it. Hopefully someone can tell me there is a built in function that can do this.</p>