T O P
Shiba_Take

How about you subtract the min and max from the total sum and divide by (the total length - 2)? No need to make new list. `return (sum(nums) - min(nums) - max(nums)) // (len(nums) - 2)`


I_am_jarvis0

I'm new too. I think it's quite neat the way you solved this though. Hope someone helps so I learn as well


kyber

You are ignoring every instance of smallest and every instance of the largest rather than only the first of each. Perhaps sort list and sum a slice ignoring two ends. Integer division uses the `//` operator.


jan2032001

ohh i read it wrong i though it said if two are the same that i exclude both. Thank you and a good idea fir me to slice and sort.


Wild_Statistician605

You could just order the list and do the average of the [1:-2] slice


mopslik

You'd want a final index of -1, not -2, since the stop value is not included in the slice. >>> L = [1, 2, 3, 4, 5] >>> L[1:-1] [2, 3, 4]