Question: I'm not sure why for the second function I get this output. Why is it printing 11, 7,5,3,2 def rp2( L, i ): if

I'm not sure why for the second function I get this output. Why is it printing 11, 7,5,3,2
def rp2( L, i ):
   if i < len(L):
       rp2( L, i+1 )
       print(L[i], end=' ')
   else:
       print()
L = [ 2, 3, 5, 7, 11 ]
rp2(L,0).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The rp2 function is a recursive function that prints the elements of a list L in reverse order Lets ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!