47836/closest-value-and-its-index-in-a-sorted-list-python
You can try this @Mahesh:
lst = [ 13.09409, 12.18347, 11.33447, 10.32184, 9.544922, 8.813385, ] target = 11.5 res = min(enumerate(lst), key=lambda x: abs(target - x[1])) # (2, 11.33447)
Hi, it is pretty simple, to be ...READ MORE
Hi, Using insert() method you can insert the ...READ MORE
Delete the List and its element: We have ...READ MORE
Hi, @Erick, To solve the “index error: list ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
You can simply the built-in function in ...READ MORE
The in-built variables and functions are defined ...READ MORE
Permutation is an arrangement of objects in ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.