I'm trying to find a more elegant way of looking up a number in a table.

Example:
I have the value 13 for column A and 9.8 for column B.
the biggest row that 13 is larger than is row 4 so I look into row 4 column B and compare that number to my column B number. Depending on if my column B number was bigger or smaller than row 4 column B I would do something.

![lookupTable](https://i.stack.imgur.com/ajNXZ.png)

This is what I have so far but it seems messy. Is there a way I could store all the floats in a list or dictionary to make this look better? I can't seem to find a way to look if a float is between another float other than just verbosely comparing each one.

```
table = []
someOtherFloat = 13.0
someFloat = 9.8

if someOtherFloat >= 21.2:
    table.insert(2, 25.4)
    if someFloat >= 25.4:
        print 'something'
    else:
        print 'something'
elif 18.8 <= someOtherFloat < 21.2:
    if someFloat >= 21.9:
        print 'something'
    else:
        print 'something else'
    table.insert(2, 21.9)
elif 14.2 <= someOtherFloat < 18.8:
    if someFloat >= 14.7:
        print 'something'
    else:
        print 'something else'
    table.insert(2, 14.7)
elif 9.0 <= someOtherFloat < 14.2:
    if someFloat >= 10.4:
        print 'something'
    else:
        print 'I should get printed by this code' # <--------------
    table.insert(2, 10.4)
elif 5.7 <= someOtherFloat < 9.0:
    if someFloat >= 7.0:
        print 'something'
    else:
        print 'something else'
    table.insert(2, 7.0)
elif 2.9 <= someOtherFloat < 5.7:
    if someFloat >= 5.0:
        print 'something'
    else:
        print 'something else'
    table.insert(2, 5.0)
elif 0.6 <= someOtherFloat < 2.9:
    if someFloat >= 3.5:
        print 'something'
    else:
        print 'something else'
    table.insert(2, 3.5)
else:    
    if someFloat >= 2.3:
        print 'something'
    else:
        print 'something else'
    table.insert(2, 2.3)

```

I've tried doing the following but it doesn't work.

```
checkme = [1.0, 2.3, 3.4]
checkme2 = ['hi', 'bye', 'hello']
def findBucket(aFloat):
    for key in checkme:
        if aFloat < key:
            print checkme2[key]
            return
    print final
    return

findBucket(3.0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 4, in findBucket
TypeError: list indices must be integers, not float

```

The following code seems to work the best

```
column_a = [21.2, 18.8, 14.2, 9.0, 5.7, 2.9, 0.6, -1.6]
column_b = [25.4, 21.9, 14.7, 10.4, 7.0, 5.0, 3.5, 2.3]

def findBucket(aFloat):
    i = 0
    while i < len(column_a):
        if aFloat > column_a[i]:
            print column_b[i]
            return
        i += 1
    return

findBucket(18.9)
21.9
findBucket(13.2)
10.4
findBucket(2.7)
3.5

```