سرگرمی و طنز ورزشی کارتون و انیمیشن علم و فن آوری خودرو و وسایل نقلیه آموزش موسیقی و هنر اخبار و سیاست حیوانات و طبیعت بازی حوادث مذهبی
۱۴۰۵/۰۳/۱۶
#4 Python Programming Exercise

Construct a recursive function that takes 2 parameters as input - a string and a given index ( of the text). The aim is to visit every character of the text (from left to right - so starting with index 0) recursively.

Good luck!

========================================================

#4 Python Programming Exercise

def process(txt, i):

# base case - when to terminate
if i == len(txt):
return

print(txt[i])

# hop to the next character in the text
process(txt, i+1)
This is the so-called tail recursion. We


===================================================