def reverse(password, position_x, position_y):
    """Reverse from position_x to position_y in password."""
    password_slice = password[position_x:position_y + 1]
    password[position_x:position_y + 1] = password_slice[::-1]
    return password