Source:
# Detect whether a string is a palindrome string
# palindrome concept: read from front to back and forward to read from the same.
hui_wen DEF (STR):
# baseline conditions
# If the string is less than 2, then the string can change palindromic string
IF len (STR) <2:
# palindromic
return True
# if a first string and the last bit is not equal to one, then the string is not a palindrome
elif STR [0] = STR [-1]:!
# palindromic not
return False
# recursive conditions
# If the string length is greater than 2, then the string is removed inclusive, again determines (recursively)
return hui_wen (STR [. 1: -1])
# test run
# print ( 'ababa whether palindrome:', hui_wen ( 'ababa' ))
running result: