Trying to find median but keep getting list indices must be integers, not float error and am not sure what to do.
sorted_data = sorted(data, key=lambda d:d.a
If you are using Python3, len(data)/2 will return you a float if len(data) is odd. Use // instead of / to get an integer result.
len(data)/2
len(data)
//
/
The statistics module is part of the standard library:
import statistics data = [1, 2, 3, 4] statistics.median(data)