As pyTony say you complicated it by use of ternary operator( a if b else c )
One thing also to remember is to remove punctuation.
Here one with translate.
from string import punctuation
word = word.lower().translate(None, punctuation)
return word == word[::-1]
print is_palindrom('Saippuakivikauppias') #True
And a test with a longer palindromic sentence.
letters = [c for c in s.lower() if c.isalpha()]
return letters == letters[::-1]
s = '''\
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!'''
print is_palindrome(s) #True
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...