创建一个脚本以找到给定字符串中最长的回文
"""
找到给定字符串中最长的回文
"""

def find_longest_palindrome(s):
	# 初始化结果
	max_length = 1
	
	# 初始化开始和结束索引
	start, end = 0, 0
	
	# 遍历输入字符串
	for i in range(1, len(s)):
				
		# 找到最长的偶数长度回文
		low, high = i-1, i
		while low >= 0 and high < len(s) and s[low] == s[high]:
			if high - low + 1 > max_length:
				start = low
				end = high
				max_length = high - low + 1
			low -= 1
			high += 1
		# 找到最长的奇数长度回文
		low, high = i-1, i+1
		while low >= 0 and high < len(s) and s[low] == s[high]:
			if high - low + 1 > max_length:
				start = low
				end = high
				max_length = high - low + 1
			low -= 1
			high += 1
	
	# 返回结果
	return s[start:end+1]
	
if __name__ == '__main__':
	s = "babad"
	print("最长的回文是：", end="")
	print(find_longest_palindrome(s))