I found this code on this site to find the second largest number:
def second_largest(numbers): m1, m2 = None, None for x in numbers: if x >
To find second smallest in the list, use can use following approach which will work if two or more elements are repeated.
def second_smallest(numbers): s = sorted(set(numbers)) return s[1]