def best_fit(li, value):
index = min(bisect_left(li, value), len(li) - <NUM_LIT:1>)<EOL>if index in (<NUM_LIT:0>, len(li)):<EOL><INDENT>return index<EOL><DEDENT>if li[index] - value < value - li[index-<NUM_LIT:1>]:<EOL><INDENT>return index<EOL><DEDENT>else:<EOL><INDENT>return index-<NUM_LIT:1><EOL><DEDENT>
For a sorted list li, returns the closest item to value