2009 104
Following up on Chapters 5 & 6 in the textbook
Morning
Review of the palindrome problem
steve suggests:
A man, a plan, a canoe, pasta, heros' rajahs, a coloratura, maps, snipe, percale, macaroni, a gag, a banana bag, a tan, a tag, a banana bag again (or a camel), a crepe, pins, Spam, a rut, a Rolo, cash, a jar, sore hats, a peon, a canal - Panama!
about this palindrome a palindromic story
One solution:
def first(word):
return word[0]
def last(word):
return word[-1]
def middle(word):
return word[1:-1]
def is_palindrome (word):
print "is_palindrome(" + word + ")"
if word == "":
return True
if first(word) == last(word):
return is_palindrome(middle(word))
else:
return False
word = raw_input("give me a word? ")
# word = "tomato"
if is_palindrome(word):
print "hey that's a palindrome!"
else:
print "that's no palindrome!"
Afternoon
(missing file: MarkupTurtles.zip)