Created
April 20, 2018 19:55
-
-
Save mightywombat/161cb298ff1201dda2f5fd8d12d29788 to your computer and use it in GitHub Desktop.
practicepython.org Ex 06
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# practicepython.org Ex 06 | |
import string | |
word = raw_input("Palindrome checker. Enter your palindrome: ") | |
#print word | |
word = word.replace(" ", "") # Removes spaces. | |
#print word | |
word = string.lower(word) # Changes all letters to lowercase. | |
#print word | |
for c in word: | |
if c in string.punctuation: | |
word = word.replace(c, "") # Removes punctuation. | |
#print word | |
start = 0 | |
while (len(word) / 2) > start: | |
end = -(start + 1) | |
if word[start] == word[end]: | |
start += 1 | |
print ("So far so good...") | |
else: | |
print ("You are not a winner.") | |
break | |
if start >= (len(word) / 2): | |
print ("Surprisingly, this is a palindrome. What are the chances?") | |
# end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment