def substitute(in_str, substitutions):
    """Substitute words in a string according to a dict.

    Parameters
    ----------
    in_str : str
        String to apply substitutions to.
    substitutions : dict
        Key-value pairs where key = word to substitute, value = new word.

    Returns
    -------
    out_str : str
        String with relevant substitutions applied.

    """
    out_str = ''

    # Cycle through all words in string
    for word in in_str.split():
        # If substitutions specifies a substitution for this word, substitute it
        if word.lower() in substitutions:
            out_str += substitutions[word.lower()] + ' '
        # Otherwise carry over the same word
        else:
            out_str += word + ' '

    return out_str