diff --git a/README.md b/README.md index 77d46c0..10a666e 100644 --- a/README.md +++ b/README.md @@ -2,27 +2,9 @@ ## Description -Write a program that asks the user for one or more sentences and then lets the user know if it is a palindrome. +A program that asks the user for one or more sentences and then lets the user know if it is a palindrome. -## Objectives - -### Learning Objectives - -After completing this assignment, you should understand: - -* Manipulating strings -* How strings are related to lists -* Recursion - -### Performance Objectives - -After completing this assignment, you should be able to: - -* Strip characters out of strings -* Change the case of strings -* Look at substrings - -## Details +## Assignment Details ### Deliverables @@ -59,4 +41,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..44ec2e6 --- /dev/null +++ b/palindrome.py @@ -0,0 +1,17 @@ +import re + +text = input("Your text: ") +regex_text = re.sub(r'[^A-Za-z\s]', "", text).lower() +backward_text = regex_text[::-1] +empty_list = [] +text_length = len(regex_text) +for i in range(text_length): + if backward_text[i] == regex_text[i]: + empty_list.append(1) + else: + empty_list.append(0) + +if 0 in empty_list: + print("is not a palindrome") +else: + print("is a palindrome") diff --git a/pico.txt b/pico.txt new file mode 100644 index 0000000..9e77a6d --- /dev/null +++ b/pico.txt @@ -0,0 +1 @@ +pico nano diff --git a/test.sh b/test.sh index 9e22849..35a3ab8 100755 --- a/test.sh +++ b/test.sh @@ -2,7 +2,7 @@ describe "palindrome.py: Determines if a text is palindromic" -prog="python palindrome.py" +prog="python3 palindrome.py" it_works_for_even_numbers() { out="$(echo 'toot' | $prog)"