Let me tell you what I mean. Let's say I have a list that consists of 75, 250, 525, and 900. And let's say a random number, 95. How can I round 95 to 250?
So far, I have only made it, so it rounds to the closest number but not the next integer.
def closest(lst, K):
return lst[min(range(len(lst)), key = lambda i: abs(lst[i]-K))]
lst = [75, 250, 525, 900]
K = 95
print(closest(lst, K))