def TrimBeginningAndEndingSlashes(path):
    """Trims beginning and ending slashes

    :Parameters:
        - `path`: str

    :Returns:
        str, path with beginning and ending slashes trimmed

    """
    if path.startswith('/'):
        # Returns substring starting from index 1 to end of the string
        path = path[1:]

    if path.endswith('/'):
        # Returns substring starting from beginning to last but one char in the string
        path = path[:-1]

    return path