I am trying to return count
in this recursive function but it always returns None. When I do print(count)
instead of return count
it gives me the correct result. Would anyone be able to tell me what I'm doing wrong? Thank you so much in advance :)
count = 0
def count_lowercase(s, low, high):
global count
if low > high:
return count
else:
if s[low] == s[low].lower():
count += 1
count_lowercase(s, low + 1, high)