Where is 'palindrome' defined?
Marko Rauhamaa
marko at pacujo.net
Mon Jun 1 05:21:45 EDT 2015
David Palao <dpalao.python at gmail.com>:
> Because "palindrome" != "parlindrome"?
> Have you read the error message? Did you try to understand it?
When you are starting with any new thing, even the simplest problems
look baffling. Once you have achieved a few successes, such error
messages start to make sense.
>>>>> def palindrome(num):
>> return str(num) == str(num)[::-1]
BTW, this simplistic function is not very practical for serious,
real-life palindromes. It does work for the naïve Finnish palindrome:
saippuakauppias
(= "a soap merchant")
However, it fails to detect:
innostunut sonni
(= "an enthusiastic bull")
let alone:
Sota-apina nakataan raastimeen.
Apelle pane emit.
Saarnaa takanani paatos.
(= "The war monkey will be chucked into a grater.
Hand the pistils to father-in-law.
Pathos does preach behind me.")
Marko
More information about the Python-list
mailing list