diff --git a/README.md b/README.md index 77d46c0..1df5fbf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ +Learned about string manipulation. # Determine if text is palindromic - +#Changed ## Description Write a program that asks the user for one or more sentences and then lets the user know if it is a palindrome. @@ -59,4 +60,4 @@ You may want to use the `re.sub` function to strip out punctuation and spaces. A * [Palindrome list](http://www.palindromelist.net/). * [String type in Python](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str). -* [Regular expression operations](https://docs.python.org/3/library/re.html). \ No newline at end of file +* [Regular expression operations](https://docs.python.org/3/library/re.html). diff --git a/palindrome.py b/palindrome.py new file mode 100644 index 0000000..88c4021 --- /dev/null +++ b/palindrome.py @@ -0,0 +1,23 @@ + +palindrome = input("What's your palindrome? ") + + +def check_palindrome(palindrome): + # for letter in palindrome: + punc = ['.', ',', ':', ';', "'", "_", "!"] + for punc_remove in punc: + palindrome = palindrome.replace(punc_remove, '') + palindrome = palindrome.lower() + palindrome_reverse = palindrome[::-1] + palindrome_reverse = palindrome_reverse.replace(' ', '') + palindrome = palindrome.replace(' ', '') + if palindrome == palindrome_reverse: + print("is a palindrome") + print(palindrome) + print(palindrome_reverse) + else: + print(palindrome) + print(palindrome_reverse) + print("is not a palindrome") + +check_palindrome(palindrome)