Valid Perfect Square - Leetcode 367 - Python