def strip(string, suffix):
    """Strip a suffix from a string if it exists:

        >>> strip('go bar a foobar', 'bar')
        'go bar a foo'
        >>> strip('go bar a foobar', 'baz')
        'go bar a foobar'
        >>> strip('allofit', 'allofit')
        ''

    """
    if string.endswith(suffix):
        string = string[:-len(suffix)]
    return string
