Why this code can't remove two maximum numbers from a list?

时间:2018-09-18 19:47:26

标签: python python-3.x

n = int(input())

arr = list(map(int, input().split()))

n = max(arr)

for a in arr:

if a == max(arr) :

    arr.remove(a)

print(max(arr))

Ans the question is to find the second highest number from a list but this code returns the highest number if there are many duplicate highest numbers.

0 个答案:

没有答案