Print arr with recursion

 # Online Python compiler (interpreter) to run Python online.

# Write Python 3 code in this online editor and run it.

arr = [1,3,5,7,9]


def print_arr(arr,index=0):

    if index == len(arr):

        return

    print(arr[index])

    print_arr(arr,index+1)

    

print_arr(arr)

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings