def count_episodes_by_director(episodes):
    """Constructs and returns a dictionary of key-value pairs that associate each director with a
    count of the episodes that they directed. The director's name comprises the key and the
    associated value a count of the number of episodes they directed. Duplicate keys are NOT
    permitted.

    Format:
        {
            < director name >: < episode count >,
            < director name >: < episode count >,
            ...
        }

    Parameters:
        episodes (list): nested episode dictionaries

    Returns:
        dict: a dictionary that store counts of the number of episodes directed
              by each director
    """
    result = {}
    for ep in range(len(episodes)):
        if episodes[ep]['episode_director'] in result:
            result[episodes[ep]['episode_director']] += 1
        else:
            result[episodes[ep]['episode_director']] = 1
    return result