Python程序检查字符串是否是回文
给定一个字符串,我们的任务是检查天气该字符串是否为回文。
算法
Step1: Enter string as an input. Step2: Using string slicing we reverse the string and compare it back to the original string. Step3: Then display the result.
范例程式码
my_string=input("Enter string:")
if(my_string==my_string[::-1]):
print("The string is a palindrome")
else:
print("The string isn't a palindrome")输出结果
Enter string:madam The string is a palindrome Enter string:python The string isn't a palindrome
热门推荐
10 新年门口花束祝福语简短
11 盘锦结婚祝福语大全简短
12 父母生日祝福语 简短独特
13 家庭恩爱祝福语简短英文
14 高考俄语祝福语大全简短
15 虎年祝福语 诗句唯美简短
16 生日婚礼祝福语简短精辟
17 虎年喝酒拜年祝福语简短
18 教师闺蜜祝福语简短