Skip to content

Commit 6f49404

Browse files
committed
palindrome
1 parent a98784d commit 6f49404

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

newcodes/answers/q57.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
# coding=utf-8
3+
4+
def palindrome(word):
5+
word_lst = [ i for i in word ]
6+
word_lst.reverse()
7+
new_word = "".join(word_lst)
8+
if word == new_word:
9+
return True
10+
else:
11+
return False
12+
13+
if __name__ == "__main__":
14+
while True:
15+
word = input("input a word:('q'-exit)")
16+
if word == "q":
17+
break
18+
else:
19+
if palindrome(word):
20+
print("{0} is a palindrome".format(word))
21+
else:
22+
print("The word is not palindrome")
23+

0 commit comments

Comments
 (0)