def add_suffix_to_filename(filename, suffix_text):
    """Append a suffix to a filename

    The name is appended before the file extension (if one exists)
    
    Examples:
        add_suffix_to_filename('my_file.txt', '_old') -> 'myfile_old.txt'
        add_suffix_to_filename('my_file', '_old') -> 'myfile_old'

    Args:
        filename: Filename string
        suffix_text: Attend string

    Returns
        Modified filename
    """
    if not '.' in filename:
        return filename + suffix_text
    pieces = filename.split('.')
    return '.'.join(pieces[:-1]) + suffix_text + '.' + pieces[-1]