I'm trying to check for a palindrome with Python. The code I have is very for-loop intensive.

def isPalindrome(n):

```    lst = [int(n) for n in str(n)]
l=len(lst)
if l==0 || l==1:
return True
elif len(lst)%2==0:
for k in range (l)
#####
else:
while (k<=((l-1)/2)):
if (list[]):
#####

for i in range (999, 100, -1):
for j in range (999,100, -1):
if isPalindrome(i*j):
print(i*j)
break```

I'm missing a lot of code here

PS: The problem is: Find the highest value product of two 3 digit integers that is also a palindrome. Nov 14, 2018 in Python 78 views

## 1 answer to this question.

A pythonic way  and the most simplest way to determine if a given value is a palindrome:

`str(n) == str(n)[::-1]`

Explanation:

• We're checking if the string representation of n equals the inverted string representation of n
• The [::-1] slice takes care of inverting the string
• After that, we compare for equality using == answered Nov 14, 2018 by
• 740 points

## How can I check for NaN in Python?

math.isnan() Checks if the float x is a ...READ MORE

+1 vote

## What's the canonical way to check for type in Python?

To check if o is an instance ...READ MORE

## Check a number is Prime or not in Python

There is an efficient way to write ...READ MORE

## How to check latest change time of each file using glob in python?

You can get the changing time from ...READ MORE

## how do i change string to a list?

suppose you have a string with a ...READ MORE

+1 vote

## how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE