Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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).
* [Regular expression operations](https://docs.python.org/3/library/re.html).
17 changes: 17 additions & 0 deletions palindrome.py
Original file line number Diff line number Diff line change
@@ -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")
1 change: 1 addition & 0 deletions pico.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pico nano
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down