回文正序和逆序一样的字符串,例如abccba

方法一

def is_palindrome1(text):
l = list(text)
l.reverse()
t1 = ''.join(l)
if t1 == text:
print 'the text is palindrome'
else:
print 'the text is not palindrome'

方法二

def is_palindrome2(text):
t1 = text[::-1]
if t1 == text:
print 'the text is palindrome'
else:
print 'the text is not palindrome'

方法三

def is_palindrome3(text):
r = True
for x in range(len(text)):
print x,text[x]
if text[x] != text[len(text)-x-1]:
print 1
r = False
break
if r == True:
print 'the text is palindrome'
else:
print 'the text is not palindrome'

判断字符串是否为回文 python的更多相关文章

  1. 用递归方法判断字符串是否是回文(Recursion Palindrome Python)

    所谓回文字符串,就是一个字符串从左到右读和从右到左读是完全一样的.比如:"level" .“aaabbaaa”. "madam"."radar&quo ...

  2. AC日记——判断字符串是否为回文 openjudge 1.7 33

    33:判断字符串是否为回文 总时间限制:  1000ms 内存限制:  65536kB 描述 输入一个字符串,输出该字符串是否回文.回文是指顺读和倒读都一样的字符串. 输入 输入为一行字符串(字符串中 ...

  3. C#进行回文检测,判断字符串是否是回文的代码

    下面代码内容是关于C#进行回文检测,判断字符串是否是回文的代码,应该是对各位朋友有些好处. Console.WriteLine("算法1:请输入一个字符串!");string st ...

  4. YTU 2802: 判断字符串是否为回文

    2802: 判断字符串是否为回文 时间限制: 1 Sec  内存限制: 128 MB 提交: 348  解决: 246 题目描述 编写程序,判断输入的一个字符串是否为回文.若是则输出"Yes ...

  5. Java - 判断字符串是否是回文

    首先,回文是指类似于“12345”,“abcdcba”的形式,即正念和反念都是一样的字符串 判断字符串是否是回文,这边介绍3种办法 将字符串翻转,判断翻转后的字符串和原字符串是否相等 public s ...

  6. C语言:判断字符串是否为回文,-函数fun将单向链表结点数据域为偶数的值累加起来。-用函数指针指向要调用的函数,并进行调用。

    //函数fun功能:用函数指针指向要调用的函数,并进行调用. #include <stdio.h> double f1(double x) { return x*x; } double f ...

  7. type-of-python作业-判断字符串是否属于回文需要忽略其中的标点、空格与大小写

    type-of-python作业 作业练习:要想检查文本是否属于回文需要忽略其中的标点.空格与大小写.例如,"Rise to vote, sir."是一段回文文本,但是我们现有的程 ...

  8. Java判断一个字符串是否是回文

    package com.spring.test; /** * 判断字符串是否为回文 * * @author liuwenlong * @create 2020-08-31 11:33:04 */ @S ...

  9. javascript判断给定字符串是否是回文

    //判断给定字符串是否是回文     function isPalindrome(word) {         var s = new Stack();         for (var i = 0 ...

随机推荐

  1. vue.js权威指南----代码解释实例

    1:P61(值绑定) <input type="checkbox" v-model="toggle" :true-value="a" ...

  2. 【转】Linux 图形界面与命令行模式切换

    原文网址:http://blog.csdn.net/ldl22847/article/details/7600368 Tip:使用环境VMware Workstation    OS:CentOS 6 ...

  3. hadoop之 hadoop日志存放路径

    环境:[root@hadp-master hadoop-2.7.4]# hadoop versionHadoop 2.7.4 Hadoop的日志大致可以分为两类: (1).Hadoop系统服务输出的日 ...

  4. POJ3565带权匹配——km算法

    题目:http://poj.org/problem?id=3565 神奇结论:当总边权最小时,任意两条边不相交! 转化为求二分图带权最小匹配. 可以用费用流做.但这里学一下km算法. https:// ...

  5. android studio安装须知

    64位linux,默认会提示mksdcard错误什么的,需要安装一个库 sudo apt- android sdk的下载,自己找代理服务器吧,哎……

  6. sdk下载地址

    http://www.androiddevtools.cn/ 容器,然后跟着下面的提示下载对应需要的包 放到对应的位置 即可

  7. Python基础之文件

    输出一行一行的,效率更高 一个任务: 主函数:

  8. HDU 2516 取石子游戏(斐波那契)

    取石子游戏 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  9. libevent源码学习

    怎么快速学习开源库比如libevent? libevent分析 - sparkliang的专栏 - 博客频道 - CSDN.NET Libevent源码分析 - luotuo44的专栏 - 博客频道 ...

  10. ubuntu 下出现E: Sub-process /usr/bin/dpkg returned an error code

    在用apt-get安装软件时出现了类似于 install-info: No dir file specified; try –help for more information.dpkg:处理 get ...