- 帖子
- 9
- 精华
- 0
- 积分
- 49
- 阅读权限
- 10
- 注册时间
- 2018-1-8
- 最后登录
- 2018-4-24
|
slist=[]
def reverse(text):
for i in text:
slist.append(i)
for l in slist:
if l==',':
slist.remove(',')
for l in slist:
if l=='.':
slist.remove('.')
for l in slist:
if l==' ':
slist.remove(' ')
print(slist)
text=(''.join(slist)).lower()
print(text)
print(text[::-1])
return text[::-1]
def is_palindrome(text):
return str(text) == str(reverse(text))
something = input("Enter text: ")
if is_palindrome(something):
print("Yes, it is a palindrome")
else:
print("No, it is not a palindrome") |
|