New course! Every coder should learn Generative AI!
Try a free lesson0
How did i get the output as 50?
def fun(pp): if len(pp)==1: return pp[0] else: price=fun(pp[1:]) if price>pp[0]: return price else: return pp[0] n=[10,20,30,40,50] print(fun(n))
2 Answers
+ 1
you shorten list from left side until one element is remaining. This is the last one.
0
Tq😊