def strip_surrounding(word):
    """
    Strip spaces in the front or back of word.

    :param word: A word (or sentence) of which we want to strip the surrounding spaces.
    :return: A string that doesn't start or end with a space.
    """
    while word and (word[0] != ' ' or word[-1] != ' '):
        if word[0] == ' ':
            word = word[1:]
        if word[-1] == ' ':
            word = word[:-1]
    return word