You have a string with leading, trailing, and in-between whitespaces; modify it in-place without using library functions so it has no leading or trailing spaces.
Because Python strings are immutable, represent the string as a mutable list of single-character strings. The function must mutate and return that list, preserve all internal spaces, and use only manual scanning and assignment rather than string trimming methods.
def trim_spaces(chars):