three_digit_nums = [i for i in range(100, 999)] def is_palindrome(n): norm = str(n) even = len(norm) % 2 == 0 if even: half = norm[:int(len(norm)/2)] other_half = [c for c in norm[int(len(norm)/2):]] other_half.reverse() for i, c in enumerate(half): if c != other_half[i]: return False else: return True else: return False products = [] for i in three_digit_nums: for j in three_digit_nums: product = i*j if is_palindrome(product): products.append(product) print(max(products))