python程序:检查字符串是否是回文(1)

来源:互联网 发布:在线端口检测 编辑:程序博客网 时间:2024/06/06 09:18

python程序:检查字符串是否是回文



#!/usr/bin/python
#Filename: user_input.py
#Function: check whether the string is palindrome or not.


def reverse(text):
  return text[::-1]


def is_palindrome(text):
  return text == reverse(text)


something = input('Enter text:')
if (is_palindrome(something)):
  print('Yes, it is a palindrome.')
else:
  print('No, it is not a palindrome.')

原创粉丝点击