8000 Challenge: Palindromes · neryuuk/learning-python@666a18c · GitHub
[go: up one dir, main page]

Skip to content

Commit 666a18c

Browse files
committed
Challenge: Palindromes
1 parent c27aafa commit 666a18c

File tree

2 files changed

+19
-40
lines changed

2 files changed

+19
-40
lines changed

Ch2 - Basics/challenge_palindromes.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import re
2+
from unidecode import unidecode
3+
4+
5+
def palindrome(test):
6+
sanitized = re.sub(r'[^a-zA-Z0-9]+', "", unidecode(test.lower()))
7+
return sanitized == sanitized[::-1]
8+
9+
10+
def main():
11+
while (True):
12+
test = input("Enter string to test for palindrome or 'exit': ")
13+
if test == 'exit':
14+
exit(0)
15+
print("Palindrome test: {}".format(palindrome(test)))
16+
17+
18+
if __name__ == "__main__":
19+
main()

Ch2 - Basics/challenge_solution.py

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0