def countChar(str, char):
‘’’
you can call helper function as countChar_(str[1:], char)
‘’’
if len(str) <= 0:
return 0
if str[0] == char:
return 1 + countChar_(str[1:], char)
else:
countChar_(str[1:], char)
in the correct result, the last block of else was something different, it was returning countChar_(str[1:], char). like
else:
countChar_(str[1:], char)
But I have simply calling the function in the else block and some of the cases are failed, I want to know why is that