+ 3
38.2 Right decision. Python
The proposed solution excludes 1 maximum and 1 minimum, although there are 2 maximum "1024" in the array. Therefore, the proposed solution is wrong Decision data = [7, 5, 6.9, 1, 8, 42, 33, 128, 1024, 2, 8, 11, 0.4, 1024, 66, 809, 11, 8.9, 1.1, 3.42, 9, 100, 444, 78] a = data.count(max(data)) b = data.count(min(data)) total = 0 for x in data: total += x total = total - (max(data) * a + min(data) * b) print(totals)
6 Answers
+ 3
Mailto: info@sololearn.com
+ 3
Task. Print the sum of all the array values except for all minimum and maximum values.
The array that is given in the task has 1 minimum value (0.4) and 2 maximum values (1024)
The proposed solution removes 1 maximum and 1 minimum, but the second maximum remains
+ 3
Илья Самарцев So 0.4 is the min and 1024 is the max and it says remove "all" max and min values. Therefore, the one 0.4 and the two 1024 values should be removed.
+ 1
Can you post full question?
I guess, it asking to subtract max, min values from list sum, then print?
0
Yes. It's wrong solution for *all
May expecting this kind of excersize i guess
print(sum(data) - max(data) - min(data))
0
Make the list as a set using set(list_name) , then u will get only unique numbers then u can use ur code