a = [1,2,39,4,13,4,5,6,7,3,23,2]
a.sort()
a = a[-2] + a[-1]
print(a)
>>> def f(seq):
... m1 = m2 = None
... for i in seq:
... if m2 is None:
... m2 = i
... elif m1 is None:
... if i > m2:
... m1, m2 = m2, i
... else:
... m1 = i
... elif i > m2:
... m1, m2 = m2, i
... elif i > m1:
... m1 = i
... return (m1, m2)
...
>>> a = [1, 2, 39, 4, 13, 4, 5, 6, 7, 3, 23, 2]
>>>
>>> f(a)
(23, 39)
>>>