def reverse(S, start, stop):
    """Reverse elements in S[start:stop] recursively"""
    if start < stop - 1:    # at least 2 elements
        S[start], S[stop-1] = S[stop-1], S[start]   # swap first with last and last with first
        return reverse(S, start+1, stop -1)         # recursive call on others