from string import Template


def substitute(template, context):
    """
    Performs string substitution.

    Args:
        template (str): The string to perform the substitution on.
        context (dict): A mapping of keys to values for substitution.

    Returns:
        str: The substituted string.
    """

    template = Template(template)

    return template.safe_substitute(context)