The program takes a string as input from the user and counts the number of palindromic substrings present in the input string. A substring is a palindrome if it reads the same forwards as it does backwards. The algorithm to count the number of palindromic substrings in the input string is as follows:
In the end, the program will print the number of palindromic substrings found in the input string
str = input("Enter The String :") res = 0 n = len(str) for i in range(n): for j in range(i, n): if (str[i] == str[j]): res = res + 1 print(res)
Enter The String :Python 6
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions