'counting the number of sub palindroms in a string, including the string it self

I want to count the number of sub palindromes in a string and count also the string itself if it's a palindrome. Single letters are not palindromes.

Example input: RRR

The palindromes here are RRR, and twice RR, so the output should be 3.

Another example: input rapal

output: 1

How can I go over the input with every possible starting point and every possible ending point? only this way I'll get every palindrome in the input. This is my attempt of doing it:

my_input = input() 

first_char = my_input[0]
last_char = my_input[len(my_input)-1]
num_of_pol = 0

for i in range(0, len(my_input), 1):
    for j in range(len(my_input)-1, 0, -1):
        while (i <= j):
            first_char = my_input[i]
            last_char = my_input[j]
            if (first_char == last_char):
                continue
            
print(num_of_pol)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source