Palindrome Index

  • + 1 comment

    Can't for the life of me figure out what's wrong with my solution - it passes 12/15 test cases.

    def palindromeIndex(s):
            for i in range(len(s) // 2):
                    j = len(s) - 1 - i
                    if (s[i] == s[j]):
                            continue
                    if (s[i] == s[j - 1]):
                            return j
                    if (s[i + 1] == s[j]):
                            return i
            return -1