def remove_extra_spaces(string):

    string = string.strip()

    last_char = ""

    i = 0
    while i < len(string):
        s = string[i]

        if s == " " and last_char == " ":
            string = string[0:i] + string[i+1:]
        else:
            i += 1

        last_char = s

    return string
strip out extra spaces in the given string
dataset/ETHPy150Open rca/PySPICE/mkwrapper.py/remove_extra_spaces