title: How to make the following python code on finding amicable pairs more efficient
body: <p>I have written a python program which finds amicable pairs in a specific range. I recon there are plenty of better ways to do this and am looking for some feedback on how to improve my code.</p>
  
  <pre><code>def d(n):
      x = []
      for i in range(1, n):
          if n % i == 0:
              x.append(i)
      return sum(x)
  
  def amicable(z,y):
      if d(z) == y and d(y) == z:
          print(z, y) 
  
  for z in range(0, 10000, 2):
      for y in range(0, 10000, 2):
          if z != y:
              amicable(z, y)
  </code></pre>
  
  <p>This code actually does what its supposed to, but its not very efficient. I have to wait awhile for the results.</p>