Javascript Regex Check If String Is Palindrome In Python Using For Loop