Rotate Function Leetcode Solution Python