def countSubstrings(s: str) -> int:
count_palindrome = 0
# i is the index of the current center of the tested palindroms
for i in range(len(s)):
count_palindrome += 1 # s[i] is a palindrome
# Palindromes with odd number of caracters (center is s[i])
j = 1
while (i - j >= 0) and (i + j < len(s)) and (s[i - j] == s[i + j]):
count_palindrome += 1
j += 1
# Palindromes with even number of caracters (center between s[i] and s[i])
j = 1
while (i - j + 1 >= 0) and (i + j < len(s)) and (s[i - j + 1] == s[i + j]):
count_palindrome += 1
j += 1
return(count_palindrome)