From 3b3a8209eac5195aa92aa203efbdf4d1c96214de Mon Sep 17 00:00:00 2001 From: SorenOlegnowicz Date: Wed, 27 May 2015 11:55:21 -0400 Subject: [PATCH 1/6] init --- pico.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 pico.txt 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 From bae6c84a8321d3e4a603bb729279824c53d0698f Mon Sep 17 00:00:00 2001 From: SorenOlegnowicz Date: Wed, 27 May 2015 21:28:26 -0400 Subject: [PATCH 2/6] regular mode --- homework_2.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 homework_2.py diff --git a/homework_2.py b/homework_2.py new file mode 100644 index 0000000..f5b3cd2 --- /dev/null +++ b/homework_2.py @@ -0,0 +1,19 @@ +import re + +text = input("Your text: ") +regex_text = re.sub(r'[^A-Za-z]', "", text).lower() +bward_text = regex_text[::-1] +elist = [] +etup = len(regex_text) +for i in range(etup): + if bward_text[i] == regex_text[i]: + elist.append(1) + else: + elist.append(0) + +print(elist) + +if 0 in elist: + print("is not a palindrome") +else: + print("is a palindrome") From 76d787532ce5a370d75d4678eada7e677646952c Mon Sep 17 00:00:00 2001 From: SorenOlegnowicz Date: Wed, 27 May 2015 22:05:51 -0400 Subject: [PATCH 3/6] a rename --- palindrome.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 palindrome.py diff --git a/palindrome.py b/palindrome.py new file mode 100644 index 0000000..f5b3cd2 --- /dev/null +++ b/palindrome.py @@ -0,0 +1,19 @@ +import re + +text = input("Your text: ") +regex_text = re.sub(r'[^A-Za-z]', "", text).lower() +bward_text = regex_text[::-1] +elist = [] +etup = len(regex_text) +for i in range(etup): + if bward_text[i] == regex_text[i]: + elist.append(1) + else: + elist.append(0) + +print(elist) + +if 0 in elist: + print("is not a palindrome") +else: + print("is a palindrome") From d638583d45855d519246e583ed83c8da005e2759 Mon Sep 17 00:00:00 2001 From: SorenOlegnowicz Date: Wed, 27 May 2015 22:08:42 -0400 Subject: [PATCH 4/6] update --- homework_2.py | 19 ------------------- test.sh | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 homework_2.py diff --git a/homework_2.py b/homework_2.py deleted file mode 100644 index f5b3cd2..0000000 --- a/homework_2.py +++ /dev/null @@ -1,19 +0,0 @@ -import re - -text = input("Your text: ") -regex_text = re.sub(r'[^A-Za-z]', "", text).lower() -bward_text = regex_text[::-1] -elist = [] -etup = len(regex_text) -for i in range(etup): - if bward_text[i] == regex_text[i]: - elist.append(1) - else: - elist.append(0) - -print(elist) - -if 0 in elist: - print("is not a palindrome") -else: - print("is a palindrome") 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)" From ac4aca7d75914666674d9cbb3c3d70eebd3c4d81 Mon Sep 17 00:00:00 2001 From: SorenOlegnowicz Date: Fri, 21 Aug 2015 16:25:32 -0400 Subject: [PATCH 5/6] cleaned up --- palindrome.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/palindrome.py b/palindrome.py index f5b3cd2..44ec2e6 100644 --- a/palindrome.py +++ b/palindrome.py @@ -1,19 +1,17 @@ import re text = input("Your text: ") -regex_text = re.sub(r'[^A-Za-z]', "", text).lower() -bward_text = regex_text[::-1] -elist = [] -etup = len(regex_text) -for i in range(etup): - if bward_text[i] == regex_text[i]: - elist.append(1) +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: - elist.append(0) - -print(elist) + empty_list.append(0) -if 0 in elist: +if 0 in empty_list: print("is not a palindrome") else: print("is a palindrome") From 056d4849a16b8601720b6283801cf119a041b90a Mon Sep 17 00:00:00 2001 From: SorenOlegnowicz Date: Fri, 21 Aug 2015 16:30:00 -0400 Subject: [PATCH 6/6] Update README.md --- README.md | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) 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).