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)`
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.
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'm new too. I think it's quite neat the way you solved this though. Hope someone helps so I learn as well
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.
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.
You could just order the list and do the average of the [1:-2] slice
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]