Im having trouble with this more advanced scenario.
I understand this:
def max(alist):
if len(alist) == 1:
return alist[0]
else:
m = max(alist[1:])
return m if m > alist[0] else alist[0]
Which finds the max number in a list using just recursion. This repeats the function slowly shrinking the list every time which I get. My problem is I need to create a function that returns the 2nd smallest number. I dont understand how to do this since you need to compare each item with the rest of the items in the list. How would I do this with only recursion and no built in functions or for loops?