Python 3 construct palindromes first and then check if prime
python\nclass Solution:\n    def primePalindrome(self, N):\n        """\n        :type N: int\n        :rtype: int\n        """\n        ndigits = len(str(N))\n
```python\nclass Solution:\n    def primePalindrome(self, N):\n        """\n        :type N: int\n        :rtype: int\n        """\n        ndigits = len(str(N))\n        while True:\n            for x in self.palindromes(ndigits):\n                if x >= N and self.isPrime(x):\n                    return x\n            ndigits += 1\n            \n    def palindromes(self, n):\n        if n == 1:\n            for i in range(10):\n                yield i\n        elif n % 2 == 0:\n            d = n // 2\n            for i in range(10**(d-1), 10**d):\n                s = str(i)\n                yield int(s + s[::-1])\n        else:\n            d = n // 2\n            for i in range(10**(d-1), 10**d):\n                s = str(i)\n                for j in range(10):\n                    yield int(s + str(j) + s[::-1])\n                    \n    def isPrime(self, x):\n        if x == 1:\n            return False\n        if x == 2:\n            return True\n        for i in range(2, int(x**0.5+1)):\n            if x % i == 0:\n                return False\n        return True\n```
[]