I decided to incorporate recursions into my code and for that I want to train using it. I have a recursive function which finds the max element in the given array.
def maxx(lst):
if len(lst) == 1:
return lst[0]
else:
m = maxx(lst[1:])
return m if m > lst[0] else lst[0]
maxx([1,3,2])
> 3
I tried to draw a sequence of events and I can't get why the code above works? Because according to what I see it should be 2 not 3. Where is my mistake? Is there a method that correctly expands the recursion and thus helps you to understand its flow?

array[0], which is 3 so you return 3, then you go up again andarray[0]is 1 so 3 goes out again. P.S. It's confusing to read that you expect the code to throw out a 2 looking for max value :)