"""
Recursive function to count the number of 'e's in a string

This function should be copied into the Python Tutor.  That way you can
see how recursion affects the call stack.

Author: Walker M. White, Lillian Lee, Anne Bracy, Daisy Fan
"""

def num_es(s):
    """
    Returns: number of 'e's in s

    Parameter: s the string to count
    Precondition s is a string
    """
    # Work on small data  (BASE CASE)
    if s == '':
        return 0
    elif len(s) == 1:
        return 1 if s[0]=='e' else 0

    # Break up the data   (RECUSIVE CASE)
    left = num_es(s[0])
    right = num_es(s[1:])

    # Combine the results
    return left+right

print(num_es('egg penne'))
print(num_es('apple'))
print(num_es('banana'))
