You are viewing a single comment's thread. Return to all comments →
You don't need that tmp var, just reorder your first condition:
n = int(input()) a = [int(x) for x in input().split()] largest = secondlargest = -100 for x in a: if x > largest: secondlargest = largest largest = x elif x > secondlargest and x != largest: secondlargest = x print(secondlargest)
Seems like cookies are disabled on this browser, please enable them to open this website
Find the Runner-Up Score!
You are viewing a single comment's thread. Return to all comments →
You don't need that tmp var, just reorder your first condition: