title: which numbers in list 2 are bigger and smaller than each number in list 1
body: <p>I am using python. I have two lists, list 1 is 7000 integers long, list 2 is 25000 integers. I want to go through each number in list 1 and find the closest number in list 2 that is bigger and the closest number that is smaller than each number in list 1, and then calculate the difference between these two numbers in list 2. So far I have:</p>
  <pre><code>for i in list1:
      for j in list 2:
          if list2[j]&lt;list1[i]:
              a = max(list2)
          elif list2[j]&gt;list1[i]:
              b = min(list2)
              interval = b-a
  </code></pre>
  <p>This doesn't seem to work. I want to find the explicit numbers in list 2 that are less than a specific number in list 1 and know the maximum, and then find out the smallest number in list 2 that is bigger than the number in list 1. Does anyone have any ideas? Thanks</p>