Aug-03-2018, 08:06 PM
(Aug-03-2018, 07:53 PM)amyvaulhausen Wrote: what I essentially need
is to find out how to perform this kind of function on approximate numbers that are with a
range of say +,- 10 values difference but also allows for decimal values
If you have a range of decimal values which are acceptable then I would suggest you round them:
from statistics import mode new_list = [] x = [12,11,10.4,12,10.3,10.4,15] for y in x: new_list.append(round(y)) print('new_list = ', new_list, 'mode of new_list = ', mode(new_list))Output:
new_list = [12, 11, 10, 12, 10, 10, 15] mode of new_list = 10Is that acceptable or must you keep the decimal values?