recursion problems python code example
Example 1: recursion python problems
def productOfArray(arr): if len(arr) == 0: return 0 if len(arr) == 1: return arr[0] else: return arr[len(arr)-1] * productOfArray(arr[:len(arr)-1])
Example 2: recursion python problems
def isPalindrom(strng): if len(strng) == 0: return True if strng[0] != strng[len(strng)-1]: return False return isPalindrome(strng[1:-1])