import re


def create_mad_lib_story(mad_lib_template, responses):
    """
    Summary of create_mad_lib_story function:  The user input responses will be used to populate the template in the proper position.

    Parameters:
    mad_lib_template (string): Madlib template from input file
    responses (array): the responses entered by user
    
    Returns:
    madlib_result (string): a string containing the Madlib template with user input reponses placed in the proper position of the template.
    """
    
    madlib_result = mad_lib_template

    prompts = re.findall(r'{[^}]+}', mad_lib_template)

    # The regex sub function is invoked to replace the matching prompt in the
    # Madlib string with the user input.  It replaces just the first occurence
    # of the matching prompt.  The madlib result string is recreated each time.
    for i in range(len(responses)):
        madlib_result = re.sub(prompts[i], responses[i], madlib_result, 1)

    return madlib_result