Skip to content

Instantly share code, notes, and snippets.

@mightywombat
Created April 20, 2018 19:55
Show Gist options
  • Save mightywombat/161cb298ff1201dda2f5fd8d12d29788 to your computer and use it in GitHub Desktop.
Save mightywombat/161cb298ff1201dda2f5fd8d12d29788 to your computer and use it in GitHub Desktop.
practicepython.org Ex 06
# 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