human
Python function to get value in a list closest to a number.
assistant
Here is a Python function to get value in a list closest to a number

import numpy as np

def closest(l, n):
    """
    Get value in a list closest to a number.

    :param l: List of numbers.
    :param n: Number.
    :return: Value in the list closest to the number.
    """
    return min(enumerate(l), key=lambda x: abs(x[1] - n))[0]

# Enter the list
l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# Enter the number
n = 5

# Calling the function
print((closest(l, n)))

#Remember to inspect code for bugs.