My first instict was to write functions to check if a number was prime or not and if the string version of the number was a palindrome or not. This took too long to execute. I instead executed my functions outside of the process and generated a static list of prime palindromes for numbers between 1 and 1003001 and checked the input against that list. If n <= i in prpalins print(i).